예제 #1
0
        public async Task <IActionResult> NewCategory(Category model, IFormFile picture)
        {
            string photoPath;

            try
            {
                if (picture != null)
                {
                    photoPath = await _environment.AddFile(picture, "/img/");

                    model.PhotoPath = photoPath;
                }
            }
            catch (Exception e)
            {
                TempData.AddOrUpdate("CategoryError", e.Message);
                return(View("NewCategory"));
            }
            var message = CategoriesLogic.AddCategory(model);

            if (message.GetErrorMessage != null)
            {
                TempData.AddOrUpdate("CategoryError", message.GetErrorMessage);
            }
            return(View("NewCategory", message.GetModel));
        }