示例#1
0
 public bool Delete(GovItemVM item)
 {
     var db = new GuvnerContext();
     var model = db.GovItems.FirstOrDefault(gi => gi.ID == item.ID);
     db.GovItems.Remove(model);
     return db.SaveChanges() != 0;
 }
示例#2
0
文件: Program.cs 项目: 1coguH/Guvner
        private static void test()
        {
            GuvnerContext db = new GuvnerContext();
            GovItem gi = new GovItem();
            gi.Text = "Human Resources";
            gi.GovItemType = (int)GovItemType.Focus;
            //gi.SomethingElse = "Whatever!";

            db.GovItems.Add(gi);
            db.SaveChanges();
        }
示例#3
0
 public bool Save(GovItemVM item)
 {
     var db = new GuvnerContext();
     if (item.ID == 0)
     {
         var m = Mapper.Map<GovItemVM, GovItem>(item);
         db.GovItems.Add(m);
     }
     else
     {
         var model = db.GovItems.FirstOrDefault(gi => gi.ID == item.ID);
         Mapper.Map<GovItemVM, GovItem>(item, model);
     }
     return db.SaveChanges() != 0;
 }