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