示例#1
0
        public ActionResult Delete(int id)
        {
            var db  = new ChrisbzdEntities();
            var set = db.Set(typeof(T));
            var c   = set.Find(id);

            set.Remove(c);
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
示例#2
0
        public ActionResult Details(int id)
        {
            var    db  = new ChrisbzdEntities();
            var    set = db.Set(typeof(T));
            object o   = null;

            if (id > 0)
            {
                o = set.Find(id);
            }
            else
            {
                o = set.Create();
            }
            return(View(o));
        }
示例#3
0
        public ActionResult Details(T o)
        {
            ChrisbzdEntities db = new ChrisbzdEntities();
            var set             = db.Set(typeof(T));

            if (this.IsNew(o))
            {
                set.Add(o);
            }
            else
            {
                db.Entry((object)o).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
示例#4
0
        public ActionResult List()
        {
            var db = new ChrisbzdEntities();

            return(View(db.Set(typeof(T))));
        }