public Task <Department> AddDepartment([FromBody] Department department) { if (String.IsNullOrEmpty(department.Name)) { throw new Exception("Не введено название отдела"); } return(_departmentsService.AddDepartment(department)); }
public async Task <ActionResult <ResponseDto <int> > > AddDepartment([FromBody] AddDepartmentDto departmentDto) { if (!ModelState.IsValid) { return(BadRequest()); } ResponseDto <int> result = await _departmentsService.AddDepartment(departmentDto); if (result.HasErrors) { return(BadRequest(result)); } return(Ok(result)); }