public async Task<ActionResult> Create(CategoryModel category) { // first, check if model is valid if (!ModelState.IsValid) { this.AddError(SharedResource.ModelStateIsNotValid); return this.View(category); } var newCategory = Mapper.Map<Category>(category); try { await this._categoryService.CreateCategory(newCategory, await this.CurrentProfileId()); } catch (ServiceValidationException exception) { ModelState.AddModelErrors(exception); return this.View(category); } this.AddSuccess(string.Format(CategoryResource.SuccessfullyAdded, category.Name)); return this.RedirectToAction(SharedConstant.Index); }
public async Task<ActionResult> DeleteConfirmed(CategoryModel model) { if (!ModelState.IsValid) { this.AddError(SharedResource.ModelStateIsNotValid); return this.RedirectToAction(SharedConstant.Index); } await this._categoryService.DeleteCategory(model.Guid); this.AddSuccess(string.Format(CategoryResource.SuccessfullyDeleted, model.Name)); return this.RedirectToAction(SharedConstant.Index); }