Ejemplo n.º 1
0
 public Task <Department> AddDepartment([FromBody] Department department)
 {
     if (String.IsNullOrEmpty(department.Name))
     {
         throw new Exception("Не введено название отдела");
     }
     return(_departmentsService.AddDepartment(department));
 }
Ejemplo n.º 2
0
        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));
        }