Exemple #1
0
 public List <Color> GetColors()
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Colors.OrderByDescending(x => x.Display).ToList());
     }
 }
Exemple #2
0
 public Category getBrandByID(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Categories.Where(x => x.ID == id).SingleOrDefault());
     }
 }
Exemple #3
0
 public List <Category> GetCategories()
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Categories.Where(x => x.Status == 1).OrderBy(x => x.DisplayOrder).ToList());
     }
 }
Exemple #4
0
 public Color GetColorByID(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Colors.Where(x => x.ID == id).SingleOrDefault());
     }
 }
Exemple #5
0
 public bool isDuplicate(string user)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Users.Where(x => x.UserName == user).ToList().Count > 0);
     }
 }
Exemple #6
0
 public Contact GetContactByType(int type)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Contacts.Where(x => x.Type == type && x.Status == true).SingleOrDefault());
     }
 }
Exemple #7
0
 public bool isDuplicateEmail(string email)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Users.Where(x => x.Email == email).ToList().Count > 0);
     }
 }
Exemple #8
0
 public List <Image> getAll()
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Images.ToList());
     }
 }
Exemple #9
0
 public List <Product> listTop(int top)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Products.OrderByDescending(x => x.ViewCount).Take(top).ToList());
     }
 }
Exemple #10
0
 public Product getOneById(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Products.Find(id));
     }
 }
Exemple #11
0
 public List <Product> getNewsProduct(int number)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Products.OrderByDescending(x => x.CreateDate).Take(number).ToList());
     }
 }
Exemple #12
0
 public int Login(String username, String pass)
 {
     using (ShoeDao db = new ShoeDao())
     {
         var re = db.Users.SingleOrDefault(x => x.UserName == username);
         if (re == null)
         {
             //Tài Khoản không tồn tại;
             return(0);
         }
         else
         {
             if (re.Password.Equals(pass))
             {
                 if (re.Status == false)
                 {
                     //"Tài khoản đang bị khóa";
                     return(-1);
                 }
                 else
                 {
                     return(1);
                 }
             }
             else
             {
                 //"Sai Mật khẩu";
                 return(-2);
             }
         }
     }
 }
Exemple #13
0
 public List <Product> getAll()
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Products.ToList());
     }
 }
Exemple #14
0
 public Image getOne(int productID)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Images.Where(x => x.ProductID == productID && x.IsAvatar == true).SingleOrDefault());
     }
 }
Exemple #15
0
 public Coupon getOne(string code)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Coupons.Where(x => x.Code == code && x.Status == 1 && x.ExpirationDate > DateTime.Now).SingleOrDefault());
     }
 }
Exemple #16
0
 public ProductCategory GetProductCategoryByID(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.ProductCategories.Where(x => x.ID == id).SingleOrDefault());
     }
 }
Exemple #17
0
 public List <Slide> getAll()
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Slides.Where(x => x.Status == true).OrderBy(x => x.DisplayOrder).ToList());
     }
 }
Exemple #18
0
 public User ViewDetail(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Users.SingleOrDefault(x => x.ID == id));
     }
 }
Exemple #19
0
 public User GetByID(String name)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.Users.SingleOrDefault(x => x.UserName == name));
     }
 }
Exemple #20
0
 public void Insert(Order order)
 {
     using (ShoeDao db = new ShoeDao())
     {
         db.Orders.Add(order);
         db.SaveChanges();
     }
 }
Exemple #21
0
 public List <OrderDetail> GetOrderDetails(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         return(db.OrderDetails.Where(x => x.CustomerID == id).OrderByDescending(x => x.CreateDate)
                .ToList());
     }
 }
Exemple #22
0
 public long Insert(User entity)
 {
     using (ShoeDao db = new ShoeDao())
     {
         db.Users.Add(entity);
         db.SaveChanges();
         return(entity.ID);
     }
 }
Exemple #23
0
 public int Insert(OrderDetail order)
 {
     using (ShoeDao db = new ShoeDao())
     {
         db.OrderDetails.Add(order);
         db.SaveChanges();
         return(order.ID);
     }
 }
Exemple #24
0
 public List <SizeProduct> GetVs()
 {
     using (ShoeDao db = new ShoeDao())
     {
         var model = from a in db.Products
                     group a by a.Size into g
                     select new SizeProduct()
         {
             size = g.Key
         };
         return(model.ToList());
     }
 }
Exemple #25
0
        public List <Product> SearchProducts(int page, int pageSize, ref int totalRecord,
                                             string name, int?brand, int?color, int?size, int?style)
        {
            using (ShoeDao db = new ShoeDao())
            {
                //var model = from a in db.Products
                //            where ((String.IsNullOrEmpty(name)) ? true : a.Name.Contains(name))
                //            && ((brand == null) ? true : a.CategoryID == brand)
                //            && ((color == null) ? true : a.Color == color)
                //            && ((size == null) ? true : a.Size == size)
                //            && ((style == null) ? true : a.TypeID == style)
                //            select new Product()
                //            {
                //                ID = a.ID,
                //                Name = a.Name,
                //                Image = a.Image,
                //                Size = a.Size,
                //                MetaTitle = a.MetaTitle,
                //                Description = a.Description,
                //                Price = a.Price,
                //                PromotionPrice = a.PromotionPrice,
                //                Quantity = a.Quantity,
                //                Color = a.Color,
                //                CategoryID = a.CategoryID,
                //                TypeID = a.TypeID,
                //                Detail = a.Detail,
                //                CreateDate = a.CreateDate,
                //                CreateBy = a.CreateBy,
                //                ModifiedDate = a.ModifiedDate,
                //                ModifiedBy = a.ModifiedBy,
                //                Status = a.Status,
                //                MetaKeyWords = a.MetaKeyWords,
                //                MetaDiscriptions = a.MetaDiscriptions,
                //                ViewCount = a.ViewCount

                //            };
                totalRecord = db.Products.Where(x => ((String.IsNullOrEmpty(name)) ? true : x.Name.Contains(name)) &&
                                                ((brand == null) ? true : x.CategoryID == brand) &&
                                                ((color == null) ? true : x.Color == color) &&
                                                ((size == null) ? true : x.Size == size) &&
                                                ((style == null) ? true : x.TypeID == style)
                                                ).Count();
                return(db.Products.Where(x => ((String.IsNullOrEmpty(name)) ? true : x.Name.Contains(name)) &&
                                         ((brand == null) ? true : x.CategoryID == brand) &&
                                         ((color == null) ? true : x.Color == color) &&
                                         ((size == null) ? true : x.Size == size) &&
                                         ((style == null) ? true : x.TypeID == style)
                                         ).OrderByDescending(x => x.CreateDate)
                       .Skip((page - 1) * pageSize).Take(pageSize).ToList());
            }
        }
Exemple #26
0
 public bool Delete(int id)
 {
     using (ShoeDao db = new ShoeDao())
     {
         try
         {
             var user = db.Users.Find(id);
             db.Users.Remove(user);
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Exemple #27
0
        public bool Update(User entity)
        {
            using (ShoeDao db = new ShoeDao())
            {
                try
                {
                    var user = db.Users.Find(entity.ID);
                    user.Name         = entity.Name;
                    user.Address      = entity.Address;
                    user.Email        = entity.Email;
                    user.ModifiedBy   = entity.ModifiedBy;
                    user.ModifiedDate = DateTime.Now;
                    user.Password     = entity.Password;

                    db.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }