Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(MenuItemModel model)
        {
            if (ModelState.IsValid)
            {
                if (!await iMenuItemRepository.EditMenuItemPost(model))
                {
                    return(NotFound());
                }
                else
                {
                    var file = HttpContext.Request.Form.Files;
                    if (file.Count > 0)
                    {
                        string webRootPath = iEnvironment.WebRootPath;
                        await iMenuItemRepository.EditImageMenuItem(model.Id, webRootPath, file);
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

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