public HttpResponseMessage Put([FromBody] Transferencia t) { TransferenciaDAO dao = new TransferenciaDAO(); string valida = t.ValidaCampoDt(); if (valida != "") { ModelState.AddModelError("Transferencia", valida); } if (ModelState.IsValid) { var i = dao.Atualizar(t); if (i > 0) { return(Request.CreateResponse(HttpStatusCode.OK, i)); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Nenhuma linha foi alterada!")); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public HttpResponseMessage Post([FromBody] Transferencia transferencia) { TransferenciaDAO dao = new TransferenciaDAO(); string valida = transferencia.ValidaCampoDt(); valida += dao.Valida(transferencia); if (valida != "") { ModelState.AddModelError("Transferencia", valida); } if (ModelState.IsValid) { dao.Adicionar(transferencia); return(Request.CreateResponse(HttpStatusCode.Created, transferencia)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }