public IHttpActionResult PutSubPage(int id, SubPage subPage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != subPage.SubPageId)
            {
                return(BadRequest());
            }

            db.Entry(subPage).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubPageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public SubPage UpsertSubPage(SubPage subPage, SubPageDBEntities db)
        {
            using (db)
            {
                if (subPage.SubPageId == default(int))
                {
                    db.SubPages.Add(subPage);
                }
                else
                {
                    db.Entry(subPage).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(subPage);
            }
        }