public async Task <IActionResult> Edit(DepartmentCreateServiceModel model) { if (!ModelState.IsValid) { return(View(model)); } var department = await this.departmentService .DepartmentExists(model.Id); if (!department) { return(NotFound()); } var success = await this.departmentService .Edit(model.Id, model.Name, model.Description, model.ImageURL); if (!success) { return(BadRequest()); } return(RedirectToAction(nameof(All))); }
public async Task <IActionResult> Create(DepartmentCreateServiceModel model) { if (ModelState.IsValid) { await this.departmentService .CreateAsync(model.Name, model.Description, model.ImageURL); return(RedirectToAction(nameof(All))); } return(View(model)); }