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