コード例 #1
0
 //[Authorize]
 public async Task <IActionResult> AddClient(ClientBindingDto dto)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         if (await _repo.ClientExist(dto.ClientName))
         {
             ClientErrorResponseDto response = new ClientErrorResponseDto {
                 Error = "Conflict", Message = "A Client with name '" + dto.ClientName + "' already exist"
             };
             return(Conflict(response));
         }
         return(Ok(await _repo.AddClient(_factory.CreateClientEntity(dto), dto)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #2
0
 //[ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(Dto.Responses.ErrorResponse))]
 public async Task <IActionResult> AddClient(ClientBindingDto dto)
 {
     return(Ok(await _repo.AddClient(_factory.CreateClientEntity(dto), dto)));
 }