public class ShopCartViewModel
{
public ShopCart shopCart { get; set; }
}
public class RealtyListViewModel
{
public IEnumerable<Realty> allRealty { get; set; }
public string currCategory { get; set; }
}
public class HomeController : Controller
{
private readonly IAllRealty _allRealty;
private readonly IRealtyCategory _allCategories;
public HomeController(IAllRealty iAllRealty, IRealtyCategory iRealtyCat)
{
_allRealty = iAllRealty;
_allCategories = iRealtyCat;
}
public ViewResult Index()
{
ViewBag.Title = "Страница с автомобилями";
RealtyListViewModel obj = new RealtyListViewModel();
obj.allRealty = _allRealty.Realty;
obj.currCategory = "Недвижимость";
return View(obj);
}
}
public class ShopCartController : Controller
{
private readonly IAllRealty _realtyRep;
private readonly ShopCart _shopCart;
public ShopCartController(IAllRealty realRep, ShopCart shopCart)
{
_realtyRep = realRep;
_shopCart = shopCart;
}
public ViewResult Index()
{
var items = _shopCart.GetShopItems();
_shopCart.listShopItems = items;
var obj = new ShopCartViewModel
{
shopCart = _shopCart
};
return View(obj);
}
public RedirectToActionResult addToCart(int id)
{
var item = _realtyRep.Realty.FirstOrDefault(i => i.id == id);
if(item != null)
{
_shopCart.AddToCart(item);
}
return RedirectToAction("Index");
}
}
P.S из переведенного выше текста мне почти ничего не понятно
https://github.com/Alexey411/gitProject/commit/a56...