public IActionResult Index() { var model = ArtikliService.GetArtikal(1); NarudzbaViewModel returnModel = new NarudzbaViewModel(); PopulateModel(ref returnModel); return(View(returnModel)); }
public IActionResult Index() { KosaricaIndexViewModel model = new KosaricaIndexViewModel(); model.TotalPrice = 0; List <Item> cart = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, CartName); if (cart.IsNullOrEmpty()) { return(RedirectToAction("Index", "Customer", new { area = "Customer" })); } // get all of the data for display view and calculate the total price of the phone foreach (var item in cart) { var artikal = artikliService.GetArtikal(item.Product.Id); var proizvodjac = proizvodjaciService.Get(artikal.ProizvodjacId.Value); ArtikalViewModel artik = new ArtikalViewModel { Id = artikal.Id, Naziv = artikal.Naziv, Popust = artikal.PopustId != null, Cijena = Converter.RoundToTwoDecimal(artikal.Cijena), StanjeNaSkladistu = artikal.StanjeNaSkladistu, Opis = artikal.Opis, KratkiOpis = artikal.KratkiOpis, Proizvodjac = proizvodjac.Naziv }; item.Product.artikal = artik; model.TotalPrice += item.Product.artikal.Cijena * item.Quantity; } model.TotalPrice = Converter.RoundToTwoDecimal(model.TotalPrice); model.Items = cart; return(View(model)); }