public HttpResponseMessage PutEnderecos(Endereco endereco) { if (endereco == null) return Request.CreateResponse(HttpStatusCode.BadRequest); try { db.Entry<Endereco>(endereco).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var result = endereco; return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao alterar endereço."); } }
public HttpResponseMessage PostEnderecos(Endereco endereco) { if (endereco == null) return Request.CreateResponse(HttpStatusCode.BadRequest); try { db.Enderecos.Add(endereco); db.SaveChanges(); var result = endereco; return Request.CreateResponse(HttpStatusCode.Created, result); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao inserir endereço."); } }