Пример #1
0
        public async Task <IActionResult> AddCake(CakeDto cakeDto)
        {
            if (!ModelState.IsValid)
            {
                var category = await _categoryRepository.GetCategories();

                return(View(new CakeCreateUpdateViewModel
                {
                    CakeDto = cakeDto,
                    Categories = category
                }));
            }
            var cake = _mapper.Map <CakeDto, Cake>(cakeDto);
            await _cakeRepository.AddCakeAsync(cake);

            await _unitOfWork.CompleteAsync();

            return(RedirectToAction("ManageCakes"));
        }