Esempio n. 1
0
        public ActionResult <PhoneViewModel> Update(Guid id, PhoneViewModel phoneViewModel)
        {
            if (id != phoneViewModel.PhoneID)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                return(_iPhoneAppService.Update(phoneViewModel));
            }

            return(NoContent());
        }
Esempio n. 2
0
        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);
        }