public IHttpActionResult PutCustomPage(int id, CustomPage customPage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customPage.PageId) { return(BadRequest()); } db.Entry(customPage).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomPageExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public CustomPage UpsertSubPage(CustomPage customPage, NewClientWebPagesDBEntities db) { using (db) { if (customPage.PageId == default(int)) { db.CustomPages.Add(customPage); } else { db.Entry(customPage).State = EntityState.Modified; } db.SaveChanges(); return(customPage); } }