Beispiel #1
0
        public static object GetData(dynamic para)
        {
            var db  = new RazorPageDemo.Models.CRMContext();
            var ret = from c in db.Employee
                      select c;

            return(ret.ToList());
        }
        public static object DelDataItem(dynamic para)
        {
            var db = new RazorPageDemo.Models.CRMContext();

            var ID = (int)para.id;

            var ret = from c in db.Employee
                      where c.Id == ID
                      select c;

            if (ret.Count() == 1)
            {
                ret.FirstOrDefault().IsValid = false;
            }
            db.SaveChanges();

            return(true);
        }
Beispiel #3
0
        public static object AddNew(dynamic para)
        {
            var db = new RazorPageDemo.Models.CRMContext();

            var item = new RazorPageDemo.Models.Employee()
            {
                Address    = para.address,
                IsValid    = true,
                Memo       = para.memo,
                Name       = para.name,
                Phone      = para.phone,
                PictureUrl = para.pictureUrl,
                Title      = para.title,
            };

            db.Employee.Add(item);
            db.SaveChanges();

            return(item.Id);
        }
        public static object Edit(dynamic para)
        {
            var ID  = (int)para.id;
            var db  = new RazorPageDemo.Models.CRMContext();
            var ret = from c in db.Employee
                      where c.Id == ID
                      select c;

            if (ret.Count() == 1)
            {
                ret.FirstOrDefault().Address = para.address;
                ret.FirstOrDefault().IsValid = para.isValid;
                ret.FirstOrDefault().Memo    = para.memo;
                ret.FirstOrDefault().Name    = para.name;
                ret.FirstOrDefault().Phone   = para.address;
                ret.FirstOrDefault().Title   = para.title;
            }

            db.SaveChanges();
            return(true);
        }