public async Task <IActionResult> Edit(int id, AddCategoryFormModel model) { if (!ModelState.IsValid) { model.ForEdit = true; return(View(model)); } await this.categories.EditAsync( id, model.Name, model.Description); TempData.AddSuccessMessage($"Category {model.Name} was edited successfully"); return(RedirectToAction(nameof(HomeController.Index), "Home", new { area = string.Empty })); }
public async Task <IActionResult> Create(AddCategoryFormModel model) { if (!ModelState.IsValid) { model.AllTrainers = await this.GetAllTrainers(); return(View(model)); } await this.categories.CreateAsync( model.Name, model.Description, model.SelectedTrainers); TempData.AddSuccessMessage($"Category {model.Name} was created successfully"); return(RedirectToAction(nameof(HomeController.Index), "Home", new { area = string.Empty })); }