Example #1
0
        public IActionResult ChangePrice()
        {
            var pies  = _pieRepository.Pies.ToList();
            var model = new ChangePiePriceViewModel
            {
                Pies = pies,
            };

            return(View("ChangePiePrice", model));
        }
Example #2
0
        public IActionResult ChangePrice(ChangePiePriceViewModel model)
        {
            var pies = _pieRepository.Pies.ToList();

            model.Pies = pies;
            if (ModelState.IsValid)
            {
                var pieToUpdate = _pieRepository.GetPieById(model.PieId);
                pieToUpdate.Price = model.Price;
                _pieRepository.Update(pieToUpdate);
                ModelState.Clear();
                ViewBag.IsAdded = true;
                ViewBag.PieName = pieToUpdate.Name;
                model.Price     = 0;
                return(View("ChangePiePrice", model));
            }

            return(View("ChangePiePrice", model));
        }