示例#1
0
        public IActionResult Update(UpdateHamperViewModel vm, int id)
        {
            Hamper hamper = _hamperRepo.GetSingle(h => h.HamperId == id);

            hamper.Name       = vm.Name;
            hamper.Price      = vm.Price;
            hamper.CategoryId = vm.SelectedCategoryId;
            hamper.Category   = _categoryRepo.GetSingle(c => c.CategoryId == vm.SelectedCategoryId);

            _hamperRepo.Update(hamper);

            return(RedirectToAction("Index"));
        }
示例#2
0
        public IActionResult Update(int id)
        {
            Hamper hamper = _hamperRepo.GetSingle(h => h.HamperId == id);
            IEnumerable <Category> categories = _categoryRepo.Query(c => c.Active == true);

            UpdateHamperViewModel vm = new UpdateHamperViewModel()
            {
                Name       = hamper.Name,
                Price      = hamper.Price,
                Categories = categories
            };

            return(View(vm));
        }