public decimal GetMaximumPrice()
 {
     using (var context = new ACContext())
     {
         return(context.Products.Max(x => x.Price));
     }
 }
 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());
     }
 }
 public Brand GetBrand(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.Brands.Find(ID));
     }
 }
Exemple #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());
     }
 }
 public Category GetCategory(int ID)
 {
     using (var context = new ACContext())
     {
         return(context.Categories.Find(ID));
     }
 }
Exemple #10
0
 public List <BasicConfiguration> GetBasicConfigurations()
 {
     using (var context = new ACContext())
     {
         return(context.BasicConfiguration.ToList());
     }
 }
Exemple #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());
                }
            }
        }
Exemple #12
0
 public BasicConfiguration GetBasicConfiguration(string Key)
 {
     using (var context = new ACContext())
     {
         return(context.BasicConfiguration.Find(Key));
     }
 }
 public List <Category> GetFeaturedCategories()
 {
     using (var context = new ACContext())
     {
         return(context.Categories.Where(x => x.IsFeatured).ToList());
     }
 }
 public List <Category> GetCategories()
 {
     using (var context = new ACContext())
     {
         return(context.Categories.ToList());
     }
 }
Exemple #15
0
 public List <ProductType> GetProductTypes()
 {
     using (var context = new ACContext())
     {
         return(context.ProductType.ToList());
     }
 }
 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);
     }
 }
Exemple #17
0
 public void UpdateBrand(Brand brand)
 {
     using (var context = new ACContext())
     {
         context.Entry(brand).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void DeleteProductSpecMapp(ProductSpecMapp productSpecMapp)
 {
     using (var context = new ACContext())
     {
         context.Entry(productSpecMapp).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
 public void DeleteCategory(Category category)
 {
     using (var context = new ACContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemple #20
0
 public void UpdateProductType(ProductType ProductType)
 {
     using (var context = new ACContext())
     {
         context.Entry(ProductType).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public ACController(ACContext context, IOptions <AppSettings> settings, IMemoryCache cache)
 {
     _context = context;
     //_context = context;
     AppSettings = settings.Value;
     //this.pathProvider = pathProvider;
     this.cache = cache;
 }
 public void SaveCategory(Category category)
 {
     using (var context = new ACContext())
     {
         category.RowAddDate = System.DateTime.Now;
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemple #23
0
 public void SaveProductType(ProductType ProductType)
 {
     using (var context = new ACContext())
     {
         ProductType.RowAddDate = System.DateTime.Now;
         context.ProductType.Add(ProductType);
         context.SaveChanges();
     }
 }
Exemple #24
0
 public void SaveBrand(Brand brand)
 {
     using (var context = new ACContext())
     {
         brand.RowAddDate = System.DateTime.Now;
         context.Brands.Add(brand);
         context.SaveChanges();
     }
 }
 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);
     }
 }
 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();
     }
 }
Exemple #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());
         }
     }
 }
        //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);
        }
        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);
            }
        }
 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();
     }
 }