Example #1
0
 public IActionResult CreateStudent(StudentWithStudiesRequest request)
 {
     try
     {
         return(Ok(_dbService.CreateStudentWithStudies(request)));
     }
     catch (DbServiceException e)
     {
         if (e.Type == DbServiceExceptionTypeEnum.NotFound)
         {
             return(NotFound(e.Message));
         }
         else if (e.Type == DbServiceExceptionTypeEnum.ValueNotUnique)
         {
             return(BadRequest(e.Message));
         }
         else
         {
             return(StatusCode(500));
         }
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }