示例#1
0
        public Admindata getSingle(int i)
        {
            Admin a = e.Admins.Find(i);

            if (a != null)
            {
                Admindata d = new Admindata();
                d.Id       = a.Id;
                d.UserName = a.UserName;
                d.Password = a.Password;
                d.Email    = a.Email;
                return(d);
            }
            return(null);
        }
示例#2
0
        public List <Admindata> selectAdmin()
        {
            var a = e.Admins.ToList();
            List <Admindata> l = new List <Admindata>();

            foreach (Admin i in a)
            {
                Admindata d = new Admindata();
                d.Id       = i.Id;
                d.UserName = i.UserName;
                d.Password = i.Password;
                d.Email    = i.Email;
                l.Add(d);
            }
            return(l);
        }
示例#3
0
        public Admindata updateAdmin(Admin a)
        {
            Admin old = e.Admins.Where(
                x => x.Id == a.Id).SingleOrDefault();

            if (old != null)
            {
                e.Entry(old).CurrentValues.SetValues(a);
                e.SaveChanges();
                Admindata d = new Admindata();
                d.Id       = a.Id;
                d.UserName = a.UserName;
                d.Password = a.Password;
                d.Email    = a.Email;
                return(d);
            }
            return(null);
        }