private void PopulateModel(ref NarudzbaViewModel 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 article
            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    += Converter.RoundToTwoDecimal(item.Product.artikal.Cijena * item.Quantity);
            }
            model.Items = cart;

            returnModel.Detalji = 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));
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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));
        }