Beispiel #1
0
 public List <Order> InProgressOrders()
 {
     using (var context = new EAContext())
     {
         return(context.Orders.Where(x => x.Status == "In Progress").ToList());
     }
 }
Beispiel #2
0
 public List <FoodandMedicine> GetFoodandMedicines()
 {
     using (var context = new EAContext())
     {
         return(context.FoodandMedicines.OrderByDescending(x => x.ID).Include(x => x.Category).ToList());
     }
 }
Beispiel #3
0
 public List <Order> AllOrders()
 {
     using (var context = new EAContext())
     {
         return(context.Orders.ToList());
     }
 }
Beispiel #4
0
 public List <Order> GetOrdersByID(string ID)
 {
     using (var context = new EAContext())
     {
         return(context.Orders.Where(x => x.UserID == ID).Include(x => x.OrderItems).Include("OrderItems.Product").ToList());
     }
 }
Beispiel #5
0
 public Order GetOrderByID(int ID)
 {
     using (var context = new EAContext())
     {
         return(context.Orders.Where(x => x.ID == ID).Include(x => x.OrderItems).Include("OrderItems.Product").FirstOrDefault());
     }
 }
Beispiel #6
0
 public FoodandMedicine GetFoodandMedicine(int?id)
 {
     using (var context = new EAContext())
     {
         return(context.FoodandMedicines.Where(x => x.ID == id).Include(x => x.Category).FirstOrDefault());
     }
 }
Beispiel #7
0
 public Category GetCategory(int id)
 {
     using (var context = new EAContext())
     {
         return(context.Categories.Find(id));
     }
 }
Beispiel #8
0
 public List <Category> GetFeaturedCategory()
 {
     using (var context = new EAContext())
     {
         return(context.Categories.Where(x => x.isFeatured && x.ImageURL != null).ToList());
     }
 }
Beispiel #9
0
 public List <Product> GetCartProducts(List <int> ids)
 {
     using (var context = new EAContext())
     {
         return(context.Products.Where(x => ids.Contains(x.ID)).ToList());
     }
 }
Beispiel #10
0
 public List <Order> DeliveredOrders()
 {
     using (var context = new EAContext())
     {
         return(context.Orders.Where(x => x.Status == "Delivered").ToList());
     }
 }
Beispiel #11
0
 public Product GetProduct(int id)
 {
     using (var context = new EAContext())
     {
         return(context.Products.Where(x => x.ID == id).Include(x => x.Category).FirstOrDefault());
     }
 }
Beispiel #12
0
 //getReview for productDetails view
 public List <Review> GetReview(int id)
 {
     using (var context = new EAContext())
     {
         return(context.Reviews.Where(x => x.Product.ID == id).ToList());
     }
 }
Beispiel #13
0
 public int GetMinimumPrice()
 {
     using (var context = new EAContext())
     {
         return((int)(context.Products.Min(x => x.Price)));
     }
 }
Beispiel #14
0
 public List <Category> GetFeaturedNotNullItemCategory()
 {
     using (var context = new EAContext())
     {
         return(context.Categories.Where(x => x.isFeatured && x.Products.Count != 0 && x.ImageURL != null).ToList());
     }
 }
Beispiel #15
0
 public List <Order> PendingOrders()
 {
     using (var context = new EAContext())
     {
         return(context.Orders.Where(x => x.Status == "Pending").ToList());
     }
 }
Beispiel #16
0
 public List <Product> GetProductsByCategory(int categoryID, int numberOfProducts)
 {
     using (var context = new EAContext())
     {
         return(context.Products.OrderByDescending(x => x.ID).Take(numberOfProducts).Where(x => (x.Category.ID == categoryID) && (x.Category.isFeatured == true)).Include(x => x.Category).ToList());
     }
 }
Beispiel #17
0
 public void UpdateProduct(Product product)
 {
     using (var context = new EAContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #18
0
 public int SaveOrder(Order order)
 {
     using (var context = new EAContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
Beispiel #19
0
 public List <Product> GetProducts()//int pageNo
 {
     using (var context = new EAContext())
     {
         context.Configuration.ProxyCreationEnabled = false;
         return(context.Products.OrderByDescending(x => x.ID).Where(x => x.Category.isFeatured == true).Include(x => x.Category).ToList());
     }
 }
Beispiel #20
0
 public void UpdateFoodandMedicine(FoodandMedicine foodandMedicine)
 {
     using (var context = new EAContext())
     {
         context.Entry(foodandMedicine).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #21
0
 public void UpdateCategory(Category category)
 {
     using (var context = new EAContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #22
0
 public void CreateCategory(Category category)
 {
     using (var context = new EAContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Beispiel #23
0
 public void CreateReview(Review review)
 {
     using (var context = new EAContext())
     {
         context.Entry(review.Product).State = EntityState.Unchanged;
         context.Reviews.Add(review);
         context.SaveChanges();
     }
 }
Beispiel #24
0
        public int SearchProductCount(string searchTxt, int?minimumPrice, int?maximumPrice, int?categoryID, int?sortBy)
        {
            using (var context = new EAContext())
            {
                var products = context.Products.Where(x => x.Category.isFeatured == true).ToList();

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

                if (!string.IsNullOrEmpty(searchTxt))
                {
                    products = products.Where(x => x.Name.ToLower().Contains(searchTxt.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.OrderBy(x => x.Price).ToList();
                        break;

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

                    case 4:
                        products = products.OrderByDescending(x => x.CreatedTime).ToList();
                        break;

                    case 5:
                        products = products.OrderBy(x => x.CreatedTime).ToList();
                        break;

                    default:
                        products = products.OrderByDescending(x => x.ID).ToList();
                        break;
                    }
                }

                return(products.Count);
            }
        }
Beispiel #25
0
        public void CreateProduct(Product product)
        {
            using (var context = new EAContext())
            {
                context.Entry(product.Category).State = EntityState.Unchanged;

                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Beispiel #26
0
        public void CreateFoodandMedicine(FoodandMedicine foodandMedicine)
        {
            using (var context = new EAContext())
            {
                context.Entry(foodandMedicine.Category).State = EntityState.Unchanged;

                context.FoodandMedicines.Add(foodandMedicine);
                context.SaveChanges();
            }
        }
Beispiel #27
0
        public void DeleteFoodandMedicine(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(Product).State = System.Data.Entity.EntityState.Deleted;

                var foodandMedicine = context.FoodandMedicines.Find(id);
                context.FoodandMedicines.Remove(foodandMedicine);
                context.SaveChanges();
            }
        }
Beispiel #28
0
        public void DeleteProduct(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(Product).State = System.Data.Entity.EntityState.Deleted;

                var product = context.Products.Find(id);
                context.Products.Remove(product);
                context.SaveChanges();
            }
        }
Beispiel #29
0
        public void DeleteCategory(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;

                var category = context.Categories.Find(id);
                context.Categories.Remove(category);
                context.SaveChanges();
            }
        }
Beispiel #30
0
        public List <Category> GetCategoriesFood()
        {
            using (var context = new EAContext())
            {
                //return context.Categories.ToList();
                return(context.Categories
                       .OrderBy(x => x.ID)

                       .Include(x => x.FoodandMedicines)
                       .ToList());
            }
        }