Example #1
0
        public async Task <IActionResult> Create(MenuItemModel model)
        {
            if (ModelState.IsValid)
            {
                if (!await iMenuItemRepository.CreateMenuItemPost(model))
                {
                    return(NotFound());
                }
                else
                {
                    string webRootPath = iEnvironment.WebRootPath;
                    var    file        = HttpContext.Request.Form.Files;
                    await iMenuItemRepository.AddImageMenuItem(webRootPath, file);
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(await iMenuItemRepository.ExistMenuItem(model, iCategoryRepository, iSubCategoryRepositiry)));
        }