Exemplo n.º 1
0
 public decimal GetMaximumPrice()
 {
     using (var context = new ACContext())
     {
         return(context.Products.Max(x => x.Price));
     }
 }
Exemplo n.º 2
0
 public List <Brand> GetBrands()
 {
     using (var context = new ACContext())
     {
         return(context.Brands.ToList());
     }
 }
 public List <ProductSpecMapp> GetProductSpecMapp()
 {
     using (var context = new ACContext())
     {
         return(context.ProductSpecMapps.Include(p => p.Product).Include(p => p.ProductSpecs).ToList());
     }
 }
 public ProductSpecs GetProductSpec(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.ProductSpecs.Find(ID));
     }
 }
 public List <ProductSpecMapp> GetProductSpecMapp(int ProductId)
 {
     using (var context = new ACContext())
     {
         return(context.ProductSpecMapps.Where(x => x.ProductID == ProductId).Include(p => p.Product).Include(p => p.ProductSpecs).ToList());
     }
 }
Exemplo n.º 6
0
 public Brand GetBrand(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.Brands.Find(ID));
     }
 }
Exemplo n.º 7
0
 public ProductType GetProductType(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.ProductType.Find(ID));
     }
 }
 public List <ProductSpecs> GetProductSpec()
 {
     using (var context = new ACContext())
     {
         return(context.ProductSpecs.OrderBy(x => x.OrderSeq).ToList());
     }
 }
Exemplo n.º 9
0
 public Category GetCategory(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.Categories.Find(ID));
     }
 }
Exemplo n.º 10
0
 public List <BasicConfiguration> GetBasicConfigurations()
 {
     using (var context = new ACContext())
     {
         return(context.BasicConfiguration.ToList());
     }
 }
Exemplo n.º 11
0
        public List <ProductType> GetProductTypes(string search, int pageNo)
        {
            int pageSize = int.Parse(BasicConfigService.Instance.GetBasicConfiguration("ListingPageSize").ConfigDescription);

            using (var context = new ACContext())
            {
                if (!String.IsNullOrEmpty(search))
                {
                    return(context.ProductType.Where(x => x.Name != null && x.Name.ToLower()
                                                     .Contains(search.ToLower()))
                           .OrderBy(x => x.ID)
                           .Skip((pageNo - 1) * pageSize)
                           .Take(pageSize)
                           .ToList());
                }
                else
                {
                    return(context.ProductType
                           .OrderBy(x => x.ID)
                           .Skip((pageNo - 1) * pageSize)
                           .Take(pageSize)
                           .ToList());
                }
            }
        }
Exemplo n.º 12
0
 public BasicConfiguration GetBasicConfiguration(string Key)
 {
     using (var context = new ACContext())
     {
         return(context.BasicConfiguration.Find(Key));
     }
 }
Exemplo n.º 13
0
 public List <Category> GetFeaturedCategories()
 {
     using (var context = new ACContext())
     {
         return(context.Categories.Where(x => x.IsFeatured).ToList());
     }
 }
Exemplo n.º 14
0
 public List <Category> GetCategories()
 {
     using (var context = new ACContext())
     {
         return(context.Categories.ToList());
     }
 }
Exemplo n.º 15
0
 public List <ProductType> GetProductTypes()
 {
     using (var context = new ACContext())
     {
         return(context.ProductType.ToList());
     }
 }
Exemplo n.º 16
0
 public Product GetProduct(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.Products.Include(x => x.Category).Include(x => x.Brand).Where(x => x.ID == ID).FirstOrDefault());
         //return context.Products.Find(ID);
     }
 }
Exemplo n.º 17
0
 public void UpdateBrand(Brand brand)
 {
     using (var context = new ACContext())
     {
         context.Entry(brand).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 18
0
 public void DeleteProductSpecMapp(ProductSpecMapp productSpecMapp)
 {
     using (var context = new ACContext())
     {
         context.Entry(productSpecMapp).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 19
0
 public void DeleteCategory(Category category)
 {
     using (var context = new ACContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 20
0
 public void UpdateProductType(ProductType ProductType)
 {
     using (var context = new ACContext())
     {
         context.Entry(ProductType).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 21
0
 public ACController(ACContext context, IOptions <AppSettings> settings, IMemoryCache cache)
 {
     _context = context;
     //_context = context;
     AppSettings = settings.Value;
     //this.pathProvider = pathProvider;
     this.cache = cache;
 }
Exemplo n.º 22
0
 public void SaveCategory(Category category)
 {
     using (var context = new ACContext())
     {
         category.RowAddDate = System.DateTime.Now;
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemplo n.º 23
0
 public void SaveProductType(ProductType ProductType)
 {
     using (var context = new ACContext())
     {
         ProductType.RowAddDate = System.DateTime.Now;
         context.ProductType.Add(ProductType);
         context.SaveChanges();
     }
 }
Exemplo n.º 24
0
 public void SaveBrand(Brand brand)
 {
     using (var context = new ACContext())
     {
         brand.RowAddDate = System.DateTime.Now;
         context.Brands.Add(brand);
         context.SaveChanges();
     }
 }
Exemplo n.º 25
0
 public List <Product> GetProducts(List <int> IDs)
 {
     using (var context = new ACContext())
     {
         //return context.Products.Where(x=> IDs.Contains(x.ID)).Include(x => x.Category).Include(x => x.Brand).ToList();
         List <Product> pl = new List <Product>();
         pl = context.Products.Where(product => IDs.Contains(product.ID)).Include(x => x.Category).Include(x => x.Brand).ToList();
         return(pl);
     }
 }
Exemplo n.º 26
0
 public void SaveProductSpecMapp(ProductSpecMapp productSpecMapp)
 {
     using (var context = new ACContext())
     {
         //productSpecMapp.RowAddDate = System.DateTime.Now;
         //context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;
         context.ProductSpecMapps.Add(productSpecMapp);
         context.SaveChanges();
     }
 }
Exemplo n.º 27
0
 public int GetProductTypesCount(string search)
 {
     using (var context = new ACContext())
     {
         if (!String.IsNullOrEmpty(search))
         {
             return(context.ProductType.Where(x => x.Name.ToLower().Contains(search.ToLower())).Count());
         }
         else
         {
             return(context.ProductType.Count());
         }
     }
 }
Exemplo n.º 28
0
        //public List<Product> GetProducts(string ProductSearch)
        //{
        //    using (var context = new ACContext())
        //    {
        //        return context.Products.ToList().FindAll(ProductSearch);
        //    }
        //}
        public int SaveProduct(Product product)
        {
            int id = 0;

            using (var context = new ACContext())
            {
                product.RowAddDate = System.DateTime.Now;
                //context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;
                context.Products.Add(product);
                context.SaveChanges();
                id = product.ID;
            }
            return(id);
        }
Exemplo n.º 29
0
        public int SearchProductsCount(string searchTerm, int?minimumPrice, int?maximumPrice, int?categoryID, int?sortBy)
        {
            using (var context = new ACContext())
            {
                var products = context.Products.ToList();

                if (categoryID.HasValue)
                {
                    products = products.Where(x => x.CategoryId == categoryID.Value).ToList();
                }

                if (!string.IsNullOrEmpty(searchTerm))
                {
                    products = products.Where(x => x.Name.ToLower().Contains(searchTerm.ToLower())).ToList();
                }

                if (minimumPrice.HasValue)
                {
                    products = products.Where(x => x.Price >= minimumPrice.Value).ToList();
                }
                if (maximumPrice.HasValue)
                {
                    products = products.Where(x => x.Price <= maximumPrice.Value).ToList();
                }

                if (sortBy.HasValue)
                {
                    switch (sortBy.Value)
                    {
                    case 2:
                        products = products.OrderByDescending(x => x.ID).Where(x => x.IsBest == true).ToList();
                        break;

                    case 3:
                        products = products.OrderBy(x => x.Price - x.AmountDis).ToList();
                        break;

                    case 4:
                        products = products.OrderByDescending(x => x.Price - x.AmountDis).ToList();
                        break;

                    default:
                        products = products.OrderByDescending(x => x.ID).ToList();
                        break;
                    }
                }
                return(products.Count);
            }
        }
Exemplo n.º 30
0
 public List <Product> GetProducts(int recordnumbers)
 {
     using (var context = new ACContext())
     {
         if (recordnumbers != 0)
         {
             return(context.Products.Include(x => x.Category).Include(x => x.Brand).OrderByDescending(x => x.ID).Take(recordnumbers).ToList());
         }
         else
         {
             return(context.Products.Include(x => x.Category).Include(x => x.Brand).ToList());
         }
         //return context.Products.ToList();
     }
 }