示例#1
0
 public void Edit(Article item)
 {
     var existing = this.Find(item.ID);
     if (existing == null)
     {
         return;
     }
     var entry = context.Entry(existing);
     entry.CurrentValues.SetValues(item);
 }
示例#2
0
        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);
        }
示例#3
0
 // To Mock out in testing
 private System.Data.Entity.Infrastructure.DbEntityEntry GetEntry(Article existing)
 {
     return context.Entry(existing);
 }
示例#4
0
 public void Remove(Article item)
 {
     var a = this.Find(item.ID);
     context.Articles.Remove(a);
 }
示例#5
0
 public void Insert(Article item)
 {
     item.Posted = DateTime.Now;
     item.Updated = DateTime.Now;
     context.Articles.Add(item);
 }