public async Task <IActionResult> CreateClient([FromBody] ClientCreationRequest creationRequest) { if (string.IsNullOrEmpty(creationRequest.Name)) { return(BadRequest()); } var client = await insuranceService.CreateClientAsync(creationRequest.Name); var response = new ClientResponse(client); return(Ok(response)); }
public async Task <IActionResult> UpdateClient([FromRoute] string clientIdString, [FromBody] ClientCreationRequest updateRequest) { if (string.IsNullOrEmpty(clientIdString) || string.IsNullOrEmpty(updateRequest.Name)) { return(BadRequest()); } Guid clientId; try { clientId = Guid.Parse(clientIdString); } catch (FormatException) { return(BadRequest()); } Client client; try { client = await insuranceService.GetClientAsync(clientId); } catch (ResourceNotFoundException) { return(NotFound()); } await insuranceService.UpdateClientAsync(clientId, updateRequest.Name); client = await insuranceService.GetClientAsync(clientId); return(Ok(client)); }