public IActionResult Index(int?id) { if (id == null) { return(RedirectToAction("Index", "Customer")); } MobitelIndexViewModel model = new MobitelIndexViewModel(); model.Mobitel = MobitelViewModel.ConvertToMobitelViewModel(mobitelService.GetMobitel(id.Value)); model.Komentari = komentarService.GetAllKomentariByPhoneId(id.Value); return(View(model)); }
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 mobitel = mobitelService.GetMobitel(item.Product.Id); item.Product.mobitel = MobitelViewModel.ConvertToMobitelViewModel(mobitel); model.TotalPrice += item.Product.mobitel.Cijena * item.Quantity; } model.TotalPrice = Converter.RoundToTwoDecimal(model.TotalPrice); model.Items = cart; return(View(model)); }
private void PopulateModel(ref NaruzbaViewModel returnModel) { KosaricaIndexViewModel model = new KosaricaIndexViewModel(); model.TotalPrice = 0; List <Item> cart = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, CartName); // get all of the data for display view and calculate the total price of the phone foreach (var item in cart) { var mobitel = mobitelService.GetMobitel(item.Product.Id); item.Product.mobitel = MobitelViewModel.ConvertToMobitelViewModel(mobitel); model.TotalPrice += Converter.RoundToTwoDecimal(item.Product.mobitel.Cijena * item.Quantity); } model.Items = cart; returnModel.Detalji = model; }
public Mobiteli GetById(int id) { return(_service.GetMobitel(id)); }