public Task <HttpResponseMessage> Put([FromBody] dynamic body) { var listAddress = _serviceAddress.AddToPerson(body.person.address); var listPhone = _servicePhone.AddToPerson(body.person.phone); var commandPerson = new UpdatePersonCommand( id: Guid.Parse((string)body.person.id), name: (string)body.person.name, birthDate: (DateTime)body.person.birthDate, genre: (EGenre)body.person.genre, address: listAddress, phone: listPhone, phototgraph: (string)body.person.photograph ); var person = _servicePerson.Update(commandPerson); _serviceAddress.CheckAddressRemoved(listAddress, person.Id); _servicePhone.CheckPhoneRemoved(listPhone, person.Id); var commandUser = new UpdateUserCommand( id: (string)body.id, password: (string)body.password, userName: (string)body.email, idPerson: person.Id ); var user = _service.Update(commandUser); return(CreateResponse(HttpStatusCode.Created, user)); }
public IActionResult Update(PersonDTO personDTO) { try { _personApplicationService.Update(PersonAssembler.ToDO(personDTO)); return(Ok()); } catch (Exception e) { Console.WriteLine(e.Message); return(new NotFoundResult()); } }
public async Task <IActionResult> Update(PersonDTO personDTO) { var personDO = Mapper.Map <Person>(personDTO); try { await _personApplicationService.Update(personDO); return(Ok(new { message = "Update Person Success!" })); } catch (Exception ex) { _logger.LogError(ex, "Update Person Error!"); return(BadRequest(new { message = ErrorMessage })); } }
[Route("edition")] //url: /api/person/edition public HttpResponseMessage Put(PersonModelEdition model) { try { if (ModelState.IsValid) { Person p = Mapper.Map <PersonModelEdition, Person>(model); appPerson.Update(p); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, GetErrorMessages())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> Update([FromBody] PersonViewModel personViewModel) { var updatedPerson = await _personAppService.Update(personViewModel); return(Accepted(updatedPerson)); }