public ActionResult <ClientConfirmationDto> AddClient(ClientCreationDto client) { try { var createdClient = ClientServices.AddClient(client); string location = LinkGenerator.GetPathByAction("GetClientById", "Client", new { createdClient.Id }); return(Created(location, createdClient)); } catch (ValidationException) { return(BadRequest()); } }
public async Task <IActionResult> DeleteClient(ClientCreationDto dto) { try { await _clientRepository.Delete(dto); return(Ok()); } catch (Exception e) { return(NotFound("This Client cannot be delete")); } }
public async Task <IActionResult> Post([FromBody] ClientCreationDto dto) { var cmd = new CreateClientCommand { DisplayName = dto.DisplayName, RedirectUri = dto.RedirectUri }; var result = await _sagaBus.InvokeAsync <CreateClientCommand, ClientCreationResult>(cmd); if (result.Succeed) { var url = Url.Action(nameof(GetById), new { id = result.Id }); return(Created(url, null)); } return(StatusCode(412, result.Message)); }
public async Task <IActionResult> CreateClient(ClientCreationDto dto) { var newClient = new ClientCreationDto { Name = dto.Name, LastName = dto.LastName, Dni = dto.Dni, Cuil = dto.Cuil, CellPhone = dto.CellPhone, BirthDate = dto.BirthDate, Email = dto.Email }; await _clientRepository.Create(newClient); return(Ok(dto)); }
public async Task <IActionResult> UpdateClient(ClientCreationDto dto) { try { var update = new ClientCreationDto { Name = dto.Name, LastName = dto.LastName, Dni = dto.Dni, Cuil = dto.Cuil, CellPhone = dto.CellPhone, BirthDate = dto.BirthDate, Email = dto.Email }; await _clientRepository.Update(dto); return(Ok(update)); } catch (Exception e) { return(NotFound("This Client cannot be changed")); } }
public ClientConfirmationDto AddClient(ClientCreationDto client) { var addedClient = ClientRepository.AddClient(new Client(Guid.NewGuid(), client.CountryId, client.Name, client.Address, client.City, client.Postal, client.Country)); return(Mapper.Map <ClientConfirmationDto>(addedClient)); }