public ActionResult Edit(EstoqueViewModel estoqueViewModel) { if (!ModelState.IsValid) { return(View(estoqueViewModel)); } estoqueViewModel = _estoqueAppService.Atualizar(estoqueViewModel); return(RedirectToAction("Index")); }
public HttpResponseMessage Put(EstoqueEdicaoViewModel model) { if (ModelState.IsValid) { try { appService.Atualizar(model); //200 - Sucesso - OK return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { //500 - Erro de Aplicação - Internal Server Error return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } } //400 - Requisição inválida - Bad Request return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidationUtil.GetErrorMessages(ModelState))); }
public HttpResponseMessage Put(EstoqueEdicaoViewModel model) { if (ModelState.IsValid) { try { appService.Atualizar(model); //HTTP 200 return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { //HTTP 500 return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message)); } } else { //HTTP 400 return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidationUtil.GetErrorMessages(ModelState))); } }