public List <Color> GetColors() { using (ShoeDao db = new ShoeDao()) { return(db.Colors.OrderByDescending(x => x.Display).ToList()); } }
public Category getBrandByID(int id) { using (ShoeDao db = new ShoeDao()) { return(db.Categories.Where(x => x.ID == id).SingleOrDefault()); } }
public List <Category> GetCategories() { using (ShoeDao db = new ShoeDao()) { return(db.Categories.Where(x => x.Status == 1).OrderBy(x => x.DisplayOrder).ToList()); } }
public Color GetColorByID(int id) { using (ShoeDao db = new ShoeDao()) { return(db.Colors.Where(x => x.ID == id).SingleOrDefault()); } }
public bool isDuplicate(string user) { using (ShoeDao db = new ShoeDao()) { return(db.Users.Where(x => x.UserName == user).ToList().Count > 0); } }
public Contact GetContactByType(int type) { using (ShoeDao db = new ShoeDao()) { return(db.Contacts.Where(x => x.Type == type && x.Status == true).SingleOrDefault()); } }
public bool isDuplicateEmail(string email) { using (ShoeDao db = new ShoeDao()) { return(db.Users.Where(x => x.Email == email).ToList().Count > 0); } }
public List <Image> getAll() { using (ShoeDao db = new ShoeDao()) { return(db.Images.ToList()); } }
public List <Product> listTop(int top) { using (ShoeDao db = new ShoeDao()) { return(db.Products.OrderByDescending(x => x.ViewCount).Take(top).ToList()); } }
public Product getOneById(int id) { using (ShoeDao db = new ShoeDao()) { return(db.Products.Find(id)); } }
public List <Product> getNewsProduct(int number) { using (ShoeDao db = new ShoeDao()) { return(db.Products.OrderByDescending(x => x.CreateDate).Take(number).ToList()); } }
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); } } } }
public List <Product> getAll() { using (ShoeDao db = new ShoeDao()) { return(db.Products.ToList()); } }
public Image getOne(int productID) { using (ShoeDao db = new ShoeDao()) { return(db.Images.Where(x => x.ProductID == productID && x.IsAvatar == true).SingleOrDefault()); } }
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()); } }
public ProductCategory GetProductCategoryByID(int id) { using (ShoeDao db = new ShoeDao()) { return(db.ProductCategories.Where(x => x.ID == id).SingleOrDefault()); } }
public List <Slide> getAll() { using (ShoeDao db = new ShoeDao()) { return(db.Slides.Where(x => x.Status == true).OrderBy(x => x.DisplayOrder).ToList()); } }
public User ViewDetail(int id) { using (ShoeDao db = new ShoeDao()) { return(db.Users.SingleOrDefault(x => x.ID == id)); } }
public User GetByID(String name) { using (ShoeDao db = new ShoeDao()) { return(db.Users.SingleOrDefault(x => x.UserName == name)); } }
public void Insert(Order order) { using (ShoeDao db = new ShoeDao()) { db.Orders.Add(order); db.SaveChanges(); } }
public List <OrderDetail> GetOrderDetails(int id) { using (ShoeDao db = new ShoeDao()) { return(db.OrderDetails.Where(x => x.CustomerID == id).OrderByDescending(x => x.CreateDate) .ToList()); } }
public long Insert(User entity) { using (ShoeDao db = new ShoeDao()) { db.Users.Add(entity); db.SaveChanges(); return(entity.ID); } }
public int Insert(OrderDetail order) { using (ShoeDao db = new ShoeDao()) { db.OrderDetails.Add(order); db.SaveChanges(); return(order.ID); } }
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()); } }
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()); } }
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); } } }
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); } } }