public async Task <IActionResult> Put([FromBody] UpdateClientDTO value) { if (ModelState.IsValid) { return(Ok(await _clientService.Update(value))); } else { return(BadRequest("Model Not Valid!")); } }
public async Task <bool> Update(UpdateClientDTO model) { _unitOfWork.ClientRepo.Update(_mapper.Map <Client>(model)); if (await _unitOfWork.Save() > 0) { return(true); } else { return(false); } }
public async Task <ActionResult> Update([FromRoute] int id, [FromBody] UpdateClientDTO clientDTO) { Client client = await _clientRepository.FindByIdAsync(id); if (client.IsNull()) { return(NotFound()); } _mapper.Map(clientDTO, client); await _clientRepository.UpdateAsync(client); return(NoContent()); }
// PUT: api/Client/5 public void Put([FromBody] UpdateClientDTO updateClient) { if (updateClient.quantity >= 0) { MvcApplication.Bus.Send("DepositMoney", new DepositMoneyCommand() { ClientID = updateClient.id, Quantity = updateClient.quantity, FromATM = bool.Parse(updateClient.inATM ?? "False") }); } else { MvcApplication.Bus.Send("WithdrawMoney", new WithdrawMoneyCommand() { ClientID = updateClient.id, Quantity = updateClient.quantity, FromATM = bool.Parse(updateClient.inATM ?? "False") }); } }
public async Task <ActionResult> UpdatePartial([FromRoute] int id, [FromBody] JsonPatchDocument <UpdateClientDTO> patchClientDTO) { Client client = await _clientRepository.FindByIdAsync(id); if (client.IsNull()) { return(NotFound()); } UpdateClientDTO clientDTO = _mapper.Map <UpdateClientDTO>(client); patchClientDTO.ApplyTo(clientDTO); if (!TryValidateModel(clientDTO)) { return(ValidationProblem(ModelState)); } _mapper.Map(clientDTO, client); await _clientRepository.UpdateAsync(client); return(NoContent()); }