public static List <LaptopDTO> GetLaptops()
        {
            List <LaptopDTO> laptops = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptops = (from laptop in db.Laptops.AsNoTracking()
                           orderby laptop.ID descending
                           select new LaptopDTO
                {
                    ID = laptop.ID,
                    TenSanPham = laptop.TenSanPham,
                    GiaSanPham = laptop.GiaSanPham,
                    SoLuong = laptop.SoLuong,
                    HinhAnhSanPham = laptop.HinhAnhSanPham,
                    IDLoaiSanPham = laptop.IDLoaiSanPham,
                    ManHinh = laptop.ManHinh,
                    CPU = laptop.CPU,
                    RAM = laptop.RAM,
                    VGA = laptop.VGA,
                    Connection = laptop.Connection,
                    HDH = laptop.HDH,
                    Nang = laptop.Nang
                }).Take(6).ToList();
            }
            return(laptops);
        }
Beispiel #2
0
        public static List <PhoneDTO> GetPhones()
        {
            List <PhoneDTO> phones = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phones = (from phone in db.Phones.AsNoTracking()
                          orderby phone.ID descending
                          select new PhoneDTO
                {
                    ID = phone.ID,
                    TenSanPham = phone.TenSanPham,
                    GiaSanPham = phone.GiaSanPham,
                    SoLuong = phone.SoLuong,
                    HinhAnhSanPham = phone.HinhAnhSanPham,
                    IDLoaiSanPham = phone.IDLoaiSanPham,
                    ManHinh = phone.ManHinh,
                    CameraTruoc = phone.CameraTruoc,
                    CameraSau = phone.CameraSau,
                    RAM = phone.RAM,
                    BoNhoTrong = phone.BoNhoTrong,
                    CPU = phone.CPU,
                    GPU = phone.GPU,
                    Pin = phone.Pin,
                    HDH = phone.HDH
                }).Take(6).ToList();
            }
            return(phones);
        }
        public static List <TabletDTO> GetTablets()
        {
            List <TabletDTO> tablets = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablets = (from tablet in db.Tablets.AsNoTracking()
                           orderby tablet.ID descending
                           select new TabletDTO
                {
                    ID = tablet.ID,
                    TenSanPham = tablet.TenSanPham,
                    GiaSanPham = tablet.GiaSanPham,
                    SoLuong = tablet.SoLuong,
                    HinhAnhSanPham = tablet.HinhAnhSanPham,
                    IDLoaiSanPham = tablet.IDLoaiSanPham,
                    ManHinh = tablet.ManHinh,
                    CameraTruoc = tablet.CameraTruoc,
                    CameraSau = tablet.CameraSau,
                    CPU = tablet.CPU,
                    GPU = tablet.GPU,
                    RAM = tablet.RAM,
                    BoNhoTrong = tablet.BoNhoTrong,
                    Connection = tablet.Connection,
                    Pin = tablet.Pin,
                    HDH = tablet.HDH
                }).Take(6).ToList();
            }
            return(tablets);
        }
        public static List <LaptopDTO> GetALLaptops()
        {
            List <LaptopDTO> laptops = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptops = db.Laptops.AsNoTracking()
                          .Select(x => new LaptopDTO
                {
                    ID             = x.ID,
                    TenSanPham     = x.TenSanPham,
                    GiaSanPham     = x.GiaSanPham,
                    SoLuong        = x.SoLuong,
                    HinhAnhSanPham = x.HinhAnhSanPham,
                    IDLoaiSanPham  = x.IDLoaiSanPham,
                    ManHinh        = x.ManHinh,
                    CPU            = x.CPU,
                    RAM            = x.RAM,
                    VGA            = x.VGA,
                    Connection     = x.Connection,
                    HDH            = x.HDH,
                    Nang           = x.Nang
                })
                          .ToList();
            }
            return(laptops);
        }
        public static List <TabletDTO> GetAllTablet()
        {
            List <TabletDTO> tablets = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablets = db.Tablets.AsNoTracking()
                          .Select(x => new TabletDTO
                {
                    ID             = x.ID,
                    TenSanPham     = x.TenSanPham,
                    GiaSanPham     = x.GiaSanPham,
                    SoLuong        = x.SoLuong,
                    HinhAnhSanPham = x.HinhAnhSanPham,
                    IDLoaiSanPham  = x.IDLoaiSanPham,
                    ManHinh        = x.ManHinh,
                    CameraTruoc    = x.CameraTruoc,
                    CameraSau      = x.CameraSau,
                    CPU            = x.CPU,
                    GPU            = x.GPU,
                    RAM            = x.RAM,
                    BoNhoTrong     = x.BoNhoTrong,
                    Connection     = x.Connection,
                    Pin            = x.Pin,
                    HDH            = x.HDH
                })
                          .ToList();
            }
            return(tablets);
        }
Beispiel #6
0
        public static List <PhoneDTO> GetALLPhone()
        {
            List <PhoneDTO> phones = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phones = db.Phones.AsNoTracking()
                         .Select(x => new PhoneDTO
                {
                    ID             = x.ID,
                    TenSanPham     = x.TenSanPham,
                    GiaSanPham     = x.GiaSanPham,
                    SoLuong        = x.SoLuong,
                    HinhAnhSanPham = x.HinhAnhSanPham,
                    IDLoaiSanPham  = x.IDLoaiSanPham,
                    ManHinh        = x.ManHinh,
                    CameraTruoc    = x.CameraTruoc,
                    CameraSau      = x.CameraSau,
                    RAM            = x.RAM,
                    BoNhoTrong     = x.BoNhoTrong,
                    CPU            = x.CPU,
                    GPU            = x.GPU,
                    Pin            = x.Pin,
                    HDH            = x.HDH
                })
                         .ToList();
            }
            return(phones);
        }
Beispiel #7
0
 public static int InsertUser(User user)
 {
     using (var db = new ThietBiOnlineEntities())
     {
         db.Users.Add(user);
         db.SaveChanges();
         return(user.ID);
     }
 }
Beispiel #8
0
        public static Phone GetSinglePhone(int ID)
        {
            Phone phone = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phone = db.Phones.AsNoTracking().SingleOrDefault(x => x.ID == ID);
            }
            return(phone);
        }
Beispiel #9
0
        public static List <Phone> Search(string valueToFind)
        {
            List <Phone> phones = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phones = db.Phones.Where(x => x.TenSanPham.Contains(valueToFind)).ToList();
            }
            return(phones);
        }
Beispiel #10
0
        public static DonHang GetSingleDonHang(int ID)
        {
            DonHang donhang = null;

            using (var db = new ThietBiOnlineEntities())
            {
                donhang = db.DonHangs.AsNoTracking().SingleOrDefault(x => x.ID == ID);
            }
            return(donhang);
        }
Beispiel #11
0
        public static List <DonHang> GetALLDonHang()
        {
            List <DonHang> donHangs = null;

            using (var db = new ThietBiOnlineEntities())
            {
                donHangs = db.DonHangs.AsNoTracking().ToList();
            }
            return(donHangs);
        }
        public static List <Laptop> GetAll()
        {
            List <Laptop> laptops = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptops = db.Laptops.OrderBy(x => x.ID).ToList();
            }
            return(laptops);
        }
        public static Laptop GetSingleLaptop(int ID, string IDLoaiSanPham)
        {
            Laptop laptop = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptop = db.Laptops.AsNoTracking().SingleOrDefault(x => (x.ID == ID) && (x.IDLoaiSanPham == IDLoaiSanPham));
            }
            return(laptop);
        }
        public static Laptop GetSingleLaptop(int ID)
        {
            Laptop laptop = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptop = db.Laptops.AsNoTracking().SingleOrDefault(x => x.ID == ID);
            }
            return(laptop);
        }
        public static List <Laptop> Search(string valueToFind)
        {
            List <Laptop> laptops = null;

            using (var db = new ThietBiOnlineEntities())
            {
                laptops = db.Laptops.Where(x => x.TenSanPham.Contains(valueToFind)).ToList();
            }
            return(laptops);
        }
Beispiel #16
0
        public static List <Phone> GetAll()
        {
            List <Phone> phones = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phones = db.Phones.OrderBy(x => x.ID).ToList();
            }
            return(phones);
        }
Beispiel #17
0
        public static User GetByID(string userName)
        {
            User user = null;

            using (var db = new ThietBiOnlineEntities())
            {
                user = db.Users.SingleOrDefault(x => x.UserName == userName);
            }
            return(user);
        }
        public static Tablet GetSingleTablet(int ID)
        {
            Tablet tablet = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablet = db.Tablets.AsNoTracking().SingleOrDefault(x => x.ID == ID);
            }
            return(tablet);
        }
        public static List <Tablet> GetAll()
        {
            List <Tablet> tablets = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablets = db.Tablets.OrderBy(x => x.ID).ToList();
            }
            return(tablets);
        }
        public static Tablet GetSingleTablet(int ID, string IDLoaiSanPham)
        {
            Tablet tablet = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablet = db.Tablets.AsNoTracking().SingleOrDefault(x => (x.ID == ID) && (x.IDLoaiSanPham == IDLoaiSanPham));
            }
            return(tablet);
        }
        public static List <Tablet> Search(string valueToFind)
        {
            List <Tablet> tablets = null;

            using (var db = new ThietBiOnlineEntities())
            {
                tablets = db.Tablets.Where(x => x.TenSanPham.Contains(valueToFind)).ToList();
            }
            return(tablets);
        }
        public static bool InsertIntoLaptop(Laptop laptop)
        {
            var result = false;

            using (var db = new ThietBiOnlineEntities())
            {
                db.Laptops.Add(laptop);
                result = db.SaveChanges() > 0 ? true : false;
            }
            return(result);
        }
Beispiel #23
0
        public static int InsertIntoDonHang(DonHang donHang)
        {
            var result = 0;

            using (var db = new ThietBiOnlineEntities())
            {
                db.DonHangs.Add(donHang);
                result = db.SaveChanges();
            }
            return(result);
        }
        public static int InsertIntoChiTietDonHangLaptop(ChiTietDonHangLaptop chiTietDonHangLaptop)
        {
            var result = 0;

            using (var db = new ThietBiOnlineEntities())
            {
                db.ChiTietDonHangLaptops.Add(chiTietDonHangLaptop);
                result = db.SaveChanges();
            }
            return(result);
        }
Beispiel #25
0
        public static bool InsertIntoPhone(Phone phone)
        {
            var result = false;

            using (var db = new ThietBiOnlineEntities())
            {
                db.Phones.Add(phone);
                result = db.SaveChanges() > 0 ? true : false;
            }
            return(result);
        }
        public static bool UpdateIntoTablet(Tablet tablet)
        {
            var result = false;

            using (var db = new ThietBiOnlineEntities())
            {
                db.Entry(tablet).State = System.Data.Entity.EntityState.Modified;
                result = db.SaveChanges() > 0 ? true : false;
            }
            return(result);
        }
Beispiel #27
0
        public static Phone GetSinglePhone(int ID, string IDLoaiSanPham)
        {
            Phone phone = null;

            using (var db = new ThietBiOnlineEntities())
            {
                phone = db.Phones.AsNoTracking().SingleOrDefault(x => (x.ID == ID) &&
                                                                 (x.IDLoaiSanPham == IDLoaiSanPham));
            }
            return(phone);
        }
        public static bool InsertIntoTablet(Tablet tablet)
        {
            var result = false;

            using (var db = new ThietBiOnlineEntities())
            {
                db.Tablets.Add(tablet);
                result = db.SaveChanges() > 0 ? true : false;
            }
            return(result);
        }
        public static bool DeleteIntoTablet(int ID)
        {
            var result = false;

            using (var db = new ThietBiOnlineEntities())
            {
                var tablet = db.Tablets.SingleOrDefault(x => x.ID == ID);
                db.Tablets.Remove(tablet);
                result = db.SaveChanges() > 0 ? true : false;
            }
            return(result);
        }
Beispiel #30
0
        public static int CheckUser(string userName, string password)
        {
            User user = null;

            using (var db = new ThietBiOnlineEntities())
            {
                user = db.Users.SingleOrDefault(x => x.UserName == userName);
            }
            if (user == null)
            {
                return(0);
            }
            else
            {
                if (user.Password == password)
                {
                    return(1);
                }
                else
                {
                    return(-2);
                }
            }
        }