Пример #1
0
        public async Task <IActionResult> UpdateCategoryAsync(UpdateCategoryBindingModel model)
        {
            var(IsSuccessed, ErrorMsg) = await _categoryBLL.UpdateCategoryAsync(model.ID, model.Title, model.AttachmentUrl);

            return(Json(new
            {
                IsSuccessed,
                ErrorMsg
            }));
        }
        public async Task <IActionResult> Update(UpdateCategoryBindingModel input)
        {
            if (!this.ModelState.IsValid)
            {
                foreach (var modelState in this.ModelState.Values)
                {
                    foreach (var error in modelState.Errors)
                    {
                        this.TempData[ErrorNotification] = error.ErrorMessage;
                    }
                }

                return(this.View(input));
            }

            int id = await this.categoryService.UpdateCategoryAsync(input.Id, input.Description, input.Name, input.Title);

            this.TempData[SuccessNotification] = string.Format(SuccessfullyUpdatedCategory, input.Name);

            return(this.RedirectToRoute("category", new { id, name = input.Name.ToSlug() }));
        }