Ejemplo n.º 1
0
        public IActionResult EditCombo(LunchComboViewModel lunchComboVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(lunchComboVM));
            }
            var lunch = _lunchRepository.GetAllLunches().First(x => x.LunchId == lunchComboVM.LunchId);

            lunch = _mapper.Map(lunchComboVM, lunch);

            _appDbContext.Lunch.Update(lunch);
            _appDbContext.SaveChanges();
            if (lunchComboVM.IsGeneric)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Special", new { id = lunch.LunchId }));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditCombo(LunchComboViewModel lunchComboVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(lunchComboVM));
            }
            var lunch = await _lunchRepository.GetLunchByIdAsync(lunchComboVM.LunchId);

            lunch = _mapper.Map(lunchComboVM, lunch);

            _appDbContext.Lunch.Update(lunch);
            await _appDbContext.SaveChangesAsync();

            if (lunchComboVM.IsGeneric)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Special", new { id = lunch.LunchId }));
            }
        }