Esempio n. 1
0
        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.");
            }
        }
Esempio n. 2
0
        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.");
            }
        }