Пример #1
0
        //***********Hash discount product

        public List <Product> GetHasDiscountProduct()
        {
            using (var context = new FAContext())
            {
                return(context.Products.Where(x => x.HasDiscount && x.ImageUrl != null).ToList());
            }
        }
 public Config GetConfig(string Key)
 {
     using (var context = new FAContext())
     {
         return(context.Configurations.Find(Key));
     }
 }
 public List <Category> GetCategories()
 {
     using (var context = new FAContext())
     {
         return(context.Categories.Include(r => r.Products).ToList());
     }
 }
Пример #4
0
 public List <Product> GetProductsByCategory(int categoryID, int pageSize)
 {
     using (var context = new FAContext())
     {
         return(context.Products.Where(x => x.Category.ID == categoryID).OrderByDescending(x => x.ID).Take(pageSize).Include(x => x.Category).ToList());
     }
 }
Пример #5
0
 public List <Product> GetLatestProducts(int numberOfProducts)
 {
     using (var context = new FAContext())
     {
         return(context.Products.OrderByDescending(x => x.ID).Take(numberOfProducts).Include(x => x.Category).ToList());
     }
 }
Пример #6
0
 public List <Product> GetProducts(int pageNo, int pageSize)
 {
     using (var context = new FAContext())
     {
         return(context.Products.OrderByDescending(x => x.ID).Skip((pageNo - 1) * pageSize).Take(pageSize).Include(x => x.Category).ToList());
     }
 }
 public Category GetCategory(int ID)
 {
     using (var context = new FAContext())
     {
         return(context.Categories.Find(ID));
     }
 }
Пример #8
0
 public List <Product> GetProducts(List <int> IDs)
 {
     using (var context = new FAContext())
     {
         return(context.Products.Where(product => IDs.Contains(product.ID)).ToList());
     }
 }
        //********************Get All category

        public List <Category> GetAllCategories()
        {
            using (var context = new FAContext())
            {
                return(context.Categories.ToList());
            }
        }
Пример #10
0
 public Product GetProduct(int ID)
 {
     using (var context = new FAContext())
     {
         return(context.Products.Where(x => x.ID == ID).Include(x => x.Category).FirstOrDefault());
     }
 }
Пример #11
0
 public int GetMaximumPrice()
 {
     using (var context = new FAContext())
     {
         return((int)(context.Products.Max(x => x.Price)));
     }
 }
        //********************Get category

        public List <Category> GetCategories(string search, int pageNo, int pageSize = 3)
        {
            using (var context = new FAContext())
            {
                if (!string.IsNullOrEmpty(search))
                {
                    return(context.Categories.Where(category => category.Name != null &&
                                                    category.Name.ToLower().Contains(search.ToLower()))
                           .OrderBy(x => x.ID)
                           .Skip((pageNo - 1) * pageSize)
                           .Take(pageSize)
                           .Include(x => x.Products)
                           .ToList());
                }
                else
                {
                    return(context.Categories
                           .OrderBy(x => x.ID)
                           .Skip((pageNo - 1) * pageSize)
                           .Take(pageSize)
                           .Include(x => x.Products)
                           .ToList());
                }
            }
        }
Пример #13
0
 public Order GetOrderByID(int ID)
 {
     using (var context = new FAContext())
     {
         return(context.Orders.Where(x => x.ID == ID).Include(x => x.OrderItems).Include("orderItems.product").FirstOrDefault());
     }
 }
        //********************Feature category

        public List <Category> GetFeaturedCategories()
        {
            using (var context = new FAContext())
            {
                return(context.Categories.Where(x => x.IsFeatured && x.ImageUrl != null).ToList());
            }
        }
Пример #15
0
        //********************Update Products

        public void UpdateProduct(Product Product)
        {
            using (var context = new FAContext())
            {
                context.Entry(Product).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
        }
Пример #16
0
 public int SaveOrder(Order order)
 {
     using (var context = new FAContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
        //********************Save category

        public void SaveCategory(Category category)
        {
            using (var context = new FAContext())
            {
                context.Categories.Add(category);
                context.SaveChanges();
            }
        }
        //********************Update category


        public void UpdateCategory(Category category)
        {
            using (var context = new FAContext())
            {
                context.Entry(category).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
        }
Пример #19
0
 public List <Product> GetProducts(int pageNo)
 {
     //int pageSize = 5;
     using (var context = new FAContext())
     {
         //return context.Products.OrderBy(x=>x.ID).Skip((pageNo-1) * pageSize).Take(pageSize).Include(x=>x.Category).ToList();
         return(context.Products.Include(x => x.Category).ToList());
     }
 }
        public int ShopPageSize()
        {
            using (var context = new FAContext())
            {
                var pageSizeConfig = context.Configurations.Find("ShopPageSize");

                return(pageSizeConfig != null?int.Parse(pageSizeConfig.value) : 6);
            }
        }
Пример #21
0
        //********************Save Products

        public void SaveProduct(Product Product)
        {
            using (var context = new FAContext())
            {
                context.Entry(Product.Category).State = System.Data.Entity.EntityState.Unchanged;

                context.Products.Add(Product);
                context.SaveChanges();
            }
        }
Пример #22
0
 public object UpdateOrderStatus(int ID, string status)
 {
     using (var context = new FAContext())
     {
         var order = context.Orders.Find(ID);
         order.status = status;
         context.Entry(order).State = EntityState.Modified;
         return(context.SaveChanges() > 0);
     }
 }
Пример #23
0
        //********************Delete Products

        public void DeleteProduct(int ID)
        {
            using (var context = new FAContext())
            {
                var Product = context.Products.Find(ID);

                context.Products.Remove(Product);

                context.SaveChanges();
            }
        }
        //********************Delete category*****

        public void DeleteCategory(int ID)
        {
            using (var context = new FAContext())
            {
                var categoty = context.Categories.Where(x => x.ID == ID).Include(x => x.Products).FirstOrDefault();

                context.Products.RemoveRange(categoty.Products);

                context.Categories.Remove(categoty);

                context.SaveChanges();
            }
        }
        //********************Get category Count

        public int GetCategoriesCount(string search)
        {
            using (var context = new FAContext())
            {
                if (!string.IsNullOrEmpty(search))
                {
                    return(context.Categories.Where(category => category.Name != null && category.Name.ToLower().Contains(search.ToLower())).Count());
                }
                else
                {
                    return(context.Categories.Count());
                }
            }
        }
Пример #26
0
 public int GetProductsCount(string search)
 {
     using (var context = new FAContext())
     {
         if (!string.IsNullOrEmpty(search))
         {
             return(context.Products.Where(product => product.Name != null &&
                                           product.Name.ToLower().Contains(search.ToLower()))
                    .Count());
         }
         else
         {
             return(context.Products.Count());
         }
     }
 }
Пример #27
0
        public int SearchProductsCount(string searchTerm, int?minimumPrice, int?maximumPrice, int?categoryID, int?sortBy)
        {
            using (var context = new FAContext())
            {
                var products = context.Products.ToList();

                if (categoryID.HasValue)
                {
                    products = products.Where(x => x.Category.ID == 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).ToList();
                        break;

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

                    default:
                        products = products.OrderByDescending(x => x.Price).ToList();
                        break;
                    }
                }
                return(products.Count);
            }
        }
Пример #28
0
        public List <Order> SearchOrders(string userID, string status, int pageNo, int pageSize)
        {
            using (var context = new FAContext())
            {
                var Orders = context.Orders.ToList();

                if (!string.IsNullOrEmpty(userID))
                {
                    Orders = Orders.Where(x => x.UserID.ToLower().Contains(userID.ToLower())).ToList();
                }
                if (!string.IsNullOrEmpty(status))
                {
                    Orders = Orders.Where(x => x.status.ToLower().Contains(status.ToLower())).ToList();
                }

                return(Orders.Skip((pageNo - 1) * pageSize).Take(pageSize).ToList());
            }
        }
Пример #29
0
        public int SearchOrdersCount(string userID, string status)
        {
            using (var context = new FAContext())
            {
                var Orders = context.Orders.ToList();

                if (!string.IsNullOrEmpty(userID))
                {
                    Orders = Orders.Where(x => x.UserID.ToLower().Contains(userID.ToLower())).ToList();
                }
                if (!string.IsNullOrEmpty(status))
                {
                    Orders = Orders.Where(x => x.status.ToLower().Contains(status.ToLower())).ToList();
                }

                return(Orders.Count);
            }
        }
Пример #30
0
 /// <summary>
 /// Used internally by the derived viewer that may also set the modelprogram
 /// </summary>
 internal void SetStateMachine(FSM fa, StateProvider stateProvider, ModelProgram mp1, Set<Transition> groupingTransitions)
 {
     // Clear the node and transition tables and the cache
     this.mp = mp1;
     nodes.Clear();
     transitions.Clear();
     //reductCache.Clear();
     this.faInfo = new FAInfo(this.stateViewer1.DefaultModelName, fa, stateProvider, mp1);
     this.finiteAutomatonContext = new FAContext(fa, stateProvider, faInfo.ReductNames.Last, mp1);
     this.finiteAutomatonContext.groupingTransitions = groupingTransitions;
     //this.reductCache[this.faInfo.ReductNames.Last] = this.finiteAutomatonContext;
     this.projectionButton.Text = "     " + faInfo.ReductNames.Last.name.ToString();
     this.projectionButton.ToolTipText = faInfo.ReductNames.Last.name.ToString();
     if (faInfo.IsProduct)
     {
         this.projectionButton.Enabled = true;
         EnableProjection();
     }
     else
     {
         this.projectionButton.Enabled = false;
     }
     graphChanged = true;
     PerformLayout();
 }
Пример #31
0
        /// <summary>
        /// Used internally by the derived viewer that may also set the modelprogram
        /// </summary>
        internal void SetStateMachine(FSM fa, StateProvider stateProvider, ModelProgram mp1, Set<Transition> groupingTransitions)
        {
            // Clear the node and transition tables and the cache
            this.mp = mp1;
            // nodes.Clear(); // not needed for mp2dot, I believe
            // transitions.Clear(); // ditto
            //reductCache.Clear();
            //this.faInfo = new FAInfo(this.stateViewer1.DefaultModelName, fa, stateProvider, mp1);
            this.faInfo = new FAInfo("Fsm", fa, stateProvider, mp1); // defined in StateView.cs
            this.finiteAutomatonContext = new FAContext(fa, stateProvider, faInfo.ReductNames.Last, mp1);
            this.finiteAutomatonContext.groupingTransitions = groupingTransitions;
            //this.reductCache[this.faInfo.ReductNames.Last] = this.finiteAutomatonContext;

            // removed code here
        }
Пример #32
0
 //Dictionary<ReductName, FAContext> reductCache = new Dictionary<ReductName, FAContext>();
 private void ShowReduct(ReductName reductName)
 {
     FAContext faContext1;
     //if (!reductCache.TryGetValue(reductName, out faContext1))
     //{
         Dictionary<Term, IState> reductStateMap;
         Dictionary<Term, IState> stateMap = new Dictionary<Term, IState>();
         foreach (Term t in faInfo.fa.States)
         {
             stateMap[t] = faInfo.stateProvider(t);
         }
         FSM fa = FSMBuilder.ProjectFromProduct(faInfo.fa, ProjectedActionSymbols(reductName.treePosition), reductName.treePosition, stateMap, out reductStateMap);
         faContext1 = new FAContext(fa, delegate(Term n) { return reductStateMap[n]; }, reductName, ProjectedModelProgram(reductName.treePosition));//+++
         //reductCache[reductName] = faContext1;
     //}
     finiteAutomatonContext = faContext1;
     graphChanged = true;
     this.selectedAglNode = null; //forget previous selected glee node
     this.selectedNode = null;     //forget previous selected corresponding node
     PerformLayout();
 }