public IHttpActionResult PutArticle(int id, Article article) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != article.id) { return(BadRequest()); } db.Entry(article).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ArticleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task InsertOrUpdate(GAPPolicies policies) { using (var context = new GapContext()) { context.Entry(policies).State = policies.EntityState.ToEntityFrameworkState(); // context.Entry(policies.GAPCustomerPolicy).State = policies.GAPCustomerPolicy.EntityState.ToEntityFrameworkState(); await context.SaveChangesAsync(); } }
public ActionResult Edit([Bind(Include = "id,name,address")] Store store) { if (ModelState.IsValid) { db.Entry(store).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(store)); }
public ActionResult Edit([Bind(Include = "id,name,description,price,totalInShelf,totalInVault,storeId")] Article article) { if (ModelState.IsValid) { db.Entry(article).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(article)); }