Ejemplo n.º 1
0
        public void InsertUpdate()
        {
            KhachSanContext context = new KhachSanContext();

            context.Accounts.AddOrUpdate(this);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void Delete(int id)
        {
            KhachSanContext context = new KhachSanContext();
            Account         ac      = context.Accounts.Where(p => p.STT == id).FirstOrDefault();

            try
            {
                context.Accounts.Remove(ac);
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public static List <DTO_Account> GetAllAccount()
        {
            KhachSanContext context = new KhachSanContext();
            var             query   = (from n in context.Accounts
                                       select new DTO_Account
            {
                STT = n.STT,
                CMND = n.CMND,
                TenDangNhap = n.TenDangNhap,
                MatKhau = n.MatKhau,
                ChucVu = n.ChucVu,
            });

            return(query.ToList());
        }
Ejemplo n.º 4
0
        public static void Delete(int cmnd)
        {
            KhachSanContext context = new KhachSanContext();
            User            u       = context.Users.Where(p => p.CMND == cmnd).FirstOrDefault();

            try
            {
                context.Users.Remove(u);
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public static List <DTO_User> GetAllUser()
        {
            KhachSanContext context = new KhachSanContext();
            var             query   = (from n in context.Users
                                       select new DTO_User
            {
                SDT = n.SDT,
                DiaChi = n.DiaChi,
                CMND = n.CMND,
                HoTen = n.HoTen,
                Sex = n.GioiTinh,
                NgaySinh = n.NgaySinh,
            });

            return(query.ToList());
        }
Ejemplo n.º 6
0
        public static Account GetAccount(int idAccount)
        {
            KhachSanContext context = new KhachSanContext();

            return(context.Accounts.Where(p => p.STT == idAccount).FirstOrDefault());
        }
Ejemplo n.º 7
0
        public static List <Account> GetAll()
        {
            KhachSanContext context = new KhachSanContext();

            return(context.Accounts.ToList());
        }
Ejemplo n.º 8
0
        public static User GetUser(int cmnd)
        {
            KhachSanContext context = new KhachSanContext();

            return(context.Users.Where(p => p.CMND == cmnd).FirstOrDefault());
        }
Ejemplo n.º 9
0
        public static List <User> GetAll()
        {
            KhachSanContext context = new KhachSanContext();

            return(context.Users.ToList());
        }