Exemple #1
0
 public Product Products_Get(int productid)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Products.Find(productid));
     }
 }
Exemple #2
0
 public List <Product> Get_prod_on_Cat(int categoryid)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Products.Where(x => x.CategoryID == categoryid).Select(x => x).ToList());
     }
 }
 public Category Categories_Get(int keyvalue)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Categories.Find(keyvalue));
     }
 }
Exemple #4
0
 public List <Category> Categories_List()
 {
     using (var context = new GroceryListContext())
     {
         return(context.Categories.OrderBy(x => x.Description).ToList());
     }
 }
Exemple #5
0
 public Category Categories_Get(int categoryid)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Categories.Find(categoryid));
     }
 }
Exemple #6
0
 public List <Product> Products_List()
 {
     using (var context = new GroceryListContext())
     {
         return(context.Products.OrderBy(x => x.ProductID).ToList());
     }
 }
Exemple #7
0
 public List <Order> Orders_UnDeliveredList()
 {
     using (var context = new GroceryListContext())
     {
         return(context.Orders.Where(x => x.PickerID == null).Select(x => x).ToList());
     }
 }
Exemple #8
0
 public Product Products_Get(int keyvalue)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Products.Find(keyvalue));
     }
 }
 public List <Category> Category_List()
 {
     using (var context = new GroceryListContext())
     {
         return(context.Categories.ToList());
     }
 }
Exemple #10
0
 public Customer Customer_Get(int orderid)
 {
     using (var context = new GroceryListContext())
     {
         return(context.Orders.Where(x => x.OrderID == orderid).Select(x => x.Customer).SingleOrDefault());
     }
 }
Exemple #11
0
 public List <Picker> Pickers_List()
 {
     using (var context = new GroceryListContext())
     {
         return(context.Pickers.OrderBy(x => x.PickerID).ToList());
     }
 }
Exemple #12
0
 public Customer Customers_Get(int orderid)
 {
     using (var context = new GroceryListContext())
     {
         //using orderid, return the associated customer
         return(context.Orders.Where(x => x.OrderID == orderid).Select(x => x.Customer).FirstOrDefault());
     }
 }
Exemple #13
0
 public void Products_Add(Product item)
 {
     using (var context = new GroceryListContext())
     {
         context.Products.Add(item);
         context.SaveChanges();
     }
 }
Exemple #14
0
 public void Products_Update(Product item)
 {
     using (var context = new GroceryListContext())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #15
0
 public List <Order> Orders_UnDeliveredList()
 {
     using (var context = new GroceryListContext())
     {
         //return all orders in a list which HAVE NOT been picked
         return(context.Orders.Where(x => x.Delivery == false).ToList());
     }
 }
        public List <Picker> Pickers_List()
        {
            using (var context = new GroceryListContext())
            {
                //return all pickers in a list -- return only the pickers that work at the store of the order ID

                return(context.Pickers.ToList());
            }
        }
Exemple #17
0
 public void Product_Delete(int productid)
 {
     using (var context = new GroceryListContext())
     {
         var exists = context.Products.Find(productid);
         context.Products.Remove(exists);
         context.SaveChanges();
     }
 }
 public List <Product> Category_GetProductNames(int categoryid)
 {
     using (var context = new GroceryListContext())
     {
         var results = from x in context.Products
                       where x.CategoryID == categoryid
                       select x;
         return(results.ToList());
     }
 }
        public GroceryListController(GroceryListContext context)
        {
            _context = context;

            if (_context.GroceryList.Count() == 0)
            {
                _context.GroceryList.Add(new GroceryItem {
                    Description = "Item1"
                });
                _context.SaveChanges();
            }
        }
Exemple #20
0
 public void Products_Delete(int productid)
 {
     using (var context = new GroceryListContext())
     {
         var existing = context.Products.Find(productid);
         if (existing == null)
         {
             throw new Exception("This Product does not exist");
         }
         context.Products.Remove(existing);
         context.SaveChanges();
     }
 }
 public List <CategoryList> Category_List()
 {
     using (var context = new GroceryListContext())
     {
         var results = from x in context.Categories
                       select new CategoryList
         {
             CategoryID  = x.CategoryID,
             Description = x.Description
         };
         return(results.OrderBy(x => x.Description).ToList());
     }
 }
 //public List<SelectionList> DisplayCategory_List()
 //{
 //    using (var context = new GroceryListContext())
 //    {
 //        var results = from x in context.Categories
 //                      select new SelectionList
 //                      {
 //                          ValueId = x.CategoryID,
 //                          DisplayText = x.Description
 //                      };
 //        return results.OrderBy(x => x.DisplayText).ToList();
 //    }
 //}
 public CategoryDescription Category_GetByPK(int categoryId)
 {
     using (var context = new GroceryListContext())
     {
         var results = (from x in context.Categories
                        where x.CategoryID == categoryId
                        select new CategoryDescription
         {
             Description = x.Description
         }).FirstOrDefault();
         return(results);
     }
 }
 public CustomerInfo CustomerDetails(int OrderID)
 {
     using (var context = new GroceryListContext())
     {
         var details = (from ord in context.Orders
                        where OrderID == ord.OrderID
                        select new CustomerInfo
         {
             CustomerID = ord.Customer.CustomerID,
             FullName = ord.Customer.FirstName + " " + ord.Customer.LastName,
             Contact = ord.Customer.Phone
         }).Single();
         return(details);
     }
 }
Exemple #24
0
 public void Product_Add(ProductList item)
 {
     using (var context = new GroceryListContext())
     {
         Product addItem = new Product
         {
             Description = item.Description,
             Price       = item.Price,
             Discount    = item.Discount,
             UnitSize    = item.UnitSize,
             CategoryID  = item.CategoryID,
             Taxable     = item.Taxable
         };
         context.Products.Add(addItem);
         context.SaveChanges();
     }
 }
        public List <KeyValueOption> ListPickers()
        {
            using (var context = new GroceryListContext())
            {
                var Pickers = (from data in context.Pickers

                               select new KeyValueOption
                {
                    Key = data.PickerID.ToString(),
                    Text = data.LastName + ", " + data.FirstName
                }).ToList();
                Pickers.Insert(0, new KeyValueOption {
                    Key = null, Text = "select a Picker"
                });
                return(Pickers);
            }
        }
Exemple #26
0
 public List <PickList> OrderLists_OrderPickList(int orderid)
 {
     using (var context = new GroceryListContext())
     {
         var results = from x in context.OrderLists
                       where x.OrderID == orderid
                       select new PickList
         {
             ProductDescription = x.Product.Description,
             QtyOrdered         = x.QtyOrdered,
             Comment            = x.CustomerComment,
             Picked             = x.QtyPicked,
             PickIssue          = x.PickIssue
         };
         return(results.ToList());
     }
 }
        public List <KeyValueOption> ListOrders()
        {
            using (var context = new GroceryListContext())
            {
                var orderID = (from data in context.Orders
                               where data.PickerID == null

                               select new KeyValueOption
                {
                    Key = data.OrderID.ToString(),
                }).ToList();
                orderID.Insert(0, new KeyValueOption {
                    Key = null, Text = "select a Order"
                });
                return(orderID);
            }
        }
Exemple #28
0
 public List <ProductList> Product_List()
 {
     using (var context = new GroceryListContext())
     {
         var results = from x in context.Products
                       select new ProductList
         {
             ProductID   = x.ProductID,
             Description = x.Description,
             Price       = x.Price,
             Discount    = x.Discount,
             UnitSize    = x.UnitSize,
             CategoryID  = x.CategoryID,
             Taxable     = x.Taxable
         };
         return(results.OrderBy(x => x.Description).ToList());
     }
 }
Exemple #29
0
 public void Product_Update(ProductList item)
 {
     using (var context = new GroceryListContext())
     {
         Product updateItem = new Product
         {
             ProductID   = item.ProductID,
             Description = item.Description,
             Price       = item.Price,
             Discount    = item.Discount,
             UnitSize    = item.UnitSize,
             CategoryID  = item.CategoryID,
             Taxable     = item.Taxable
         };
         context.Entry(updateItem).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #30
0
 public List <PickList> OrderLists_OrderPickList(int orderid)
 {
     using (var context = new GroceryListContext())
     {
         //using orderid, return all the order details for that order
         //use a LINQ query that selects the information needed for a list of PickList(P)
         List <PickList> pickedList = (from x in context.OrderLists where x.Order.OrderID.Equals(orderid)
                                       select new PickList
         {
             OrderListID = x.OrderListID,
             ProductDescription = x.Product.Description,
             Quantity = x.QtyOrdered,
             Comment = x.CustomerComment,
             QuantityPicked = x.QtyPicked,
             PickIssue = x.PickIssue
         }).ToList();
         return(pickedList);
     }
 }