public void Edit(Article item) { var existing = this.Find(item.ID); if (existing == null) { return; } var entry = context.Entry(existing); entry.CurrentValues.SetValues(item); }
public ActionResult Create(/*[Bind(Include = "ID,Posted,Updatd,Title,Content")]*/ Article article) { if (ModelState.IsValid) { repo.Insert(article); repo.Save(); return RedirectToAction("Index"); } return View(article); }
// To Mock out in testing private System.Data.Entity.Infrastructure.DbEntityEntry GetEntry(Article existing) { return context.Entry(existing); }
public void Remove(Article item) { var a = this.Find(item.ID); context.Articles.Remove(a); }
public void Insert(Article item) { item.Posted = DateTime.Now; item.Updated = DateTime.Now; context.Articles.Add(item); }