public HttpResponseMessage PutMunicipios(Municipio municipio) { if (municipio == null) return Request.CreateResponse(HttpStatusCode.BadRequest); try { db.Entry<Municipio>(municipio).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var result = municipio; return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao alterar municipio."); } }
public HttpResponseMessage PostMunicipios(Municipio municipio) { if (municipio == null) return Request.CreateResponse(HttpStatusCode.BadRequest); try { db.Municipios.Add(municipio); db.SaveChanges(); var result = municipio; return Request.CreateResponse(HttpStatusCode.Created, result); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao inserir municipio."); } }