public ActionResult <PhoneViewModel> Update(Guid id, PhoneViewModel phoneViewModel) { if (id != phoneViewModel.PhoneID) { return(BadRequest()); } if (ModelState.IsValid) { return(_iPhoneAppService.Update(phoneViewModel)); } return(NoContent()); }
public Task <HttpResponseMessage> PutPhone(PhoneViewModel phoneViewModel) { HttpResponseMessage response = new HttpResponseMessage(); try { var phone = Mapper.Map <PhoneViewModel, Phone>(phoneViewModel); _service.Update(phone); response = Request.CreateResponse(HttpStatusCode.OK, "Telefone alterado com sucesso."); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } var tsc = new TaskCompletionSource <HttpResponseMessage>(); tsc.SetResult(response); return(tsc.Task); }