public async Task <IActionResult> EditCake(int id, [FromForm] CakeDto cakeDto) { if (!ModelState.IsValid) { var category = await _categoryRepository.GetCategories(); return(View(new CakeCreateUpdateViewModel { Categories = category, CakeDto = cakeDto })); } var cake = _mapper.Map <CakeDto, Cake>(cakeDto); cake.Id = id; _cakeRepository.UpdateCake(cake); await _unitOfWork.CompleteAsync(); return(RedirectToAction("ManageCakes")); }