Пример #1
0
 public List <Message> AllMessages()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Messages.ToList());
     }
 }
Пример #2
0
 public List <OrderDetail> GetOrderDetailsByItemCode(int orderId, string productCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.OrderDetails.Include(d => d.Product).Include(d => d.Size).Where(d => d.OrderID == orderId && d.Product.ProductCode == productCode && d.DeleteFlag != true).ToList());
     }
 }
Пример #3
0
 public List <Customer> AllCustomers()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Customers.Include(c => c.Orders).Where(c => c.DeleteFlag != true).OrderBy(c => c.LastName).ToList());
     }
 }
Пример #4
0
 public Customer GetCustomerById(int custId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Customers.Where(c => c.CustomerID == custId).FirstOrDefault());
     }
 }
Пример #5
0
 public Product ProductByID(int pId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Products.Where(p => p.ProductID == pId).Include(p => p.ProductsSizes.Select(x => x.Size)).Include(p => p.Category).FirstOrDefault());
     }
 }
Пример #6
0
 public void AddProductSizes(List <ProductsSize> ps)
 {
     using (var ctx = new BirovAmContext())
     {
         foreach (ProductsSize s in ps)
         {
             ProductsSize prs = ctx.ProductsSizes.Where(i => i.ProductID == s.ProductID && i.SizeID == s.SizeID).FirstOrDefault();
             if (prs == null)
             {
                 if (s.Included)
                 {
                     ctx.ProductsSizes.Add(s);
                 }
             }
             else
             {
                 if (s.Included)
                 {
                     if (prs.Stock != s.Stock)
                     {
                         prs.Stock = s.Stock;
                     }
                 }
                 else
                 {
                     ctx.Entry(prs).State = EntityState.Deleted;
                 }
             }
             ctx.SaveChanges();
         }
     }
 }
Пример #7
0
 public Size SizeById(int id)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Sizes.Include(s => s.Categories).Where(s => s.SizeID == id).FirstOrDefault());
     }
 }
Пример #8
0
 public IEnumerable <Size> AllSizes()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Sizes.Include(s => s.Categories).Where(s => s.DeleteFlag != true).OrderBy(s => s.SizeCode).ToList());
     }
 }
Пример #9
0
 public Category CategoryById(int id)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.Where(c => c.CategoryID == id).FirstOrDefault());
     }
 }
Пример #10
0
 public OrderDetail GetOrderDetailByItemCodeAndSizeCode(int oId, string pCode, string sCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.OrderDetails.Include(d => d.Product).Include(d => d.Size).Where(d => d.OrderID == oId && d.Product.ProductCode == pCode && d.Size.SizeCode == sCode && d.DeleteFlag != true).FirstOrDefault());
     }
 }
Пример #11
0
 public List <PaymentRecord> PaymentRecordsForOrder(int oId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.PaymentRecords.Where(p => p.OrderID == oId).ToList());
     }
 }
Пример #12
0
 public bool DoesItemExistInOrder(int orderId, int pId, int sId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.OrderDetails.Include(d => d.Order).Any(d => d.Order.OrderID == orderId && d.ProductID == pId && d.SizeID == sId && d.DeleteFlag != true));
     }
 }
Пример #13
0
 public OrderDetail GetOrderDetailByOrderDetailId(int odId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.OrderDetails.Include(d => d.Product).Include(d => d.Size).Where(d => d.OrderDetailID == odId).FirstOrDefault());
     }
 }
Пример #14
0
 public Order GetOrderByCustomerId(int custId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Orders.Include(o => o.Customer).Where(o => o.Customer.CustomerID == custId && o.DeleteFlag != true).FirstOrDefault());
     }
 }
Пример #15
0
 public Product FindProductByItemCode(string itemCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Products.Where(p => p.ProductCode == itemCode).FirstOrDefault());
     }
 }
Пример #16
0
 public List <OrderDetail> GetOrderDetailsByOrderId(int orderId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.OrderDetails.Include(od => od.Product).Include(od => od.Size).Where(od => od.OrderID == orderId && od.DeleteFlag != true).OrderBy(d => d.Product.ProductCode).ToList());
     }
 }
Пример #17
0
 public List <Size> SizesForProduct(int productId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Sizes.Where(s => s.ProductsSizes.Any(ps => ps.ProductID == productId) && s.DeleteFlag != true).ToList());
     }
 }
Пример #18
0
 public Customer FindCustomerByPhoneNumber(string phoneNumber)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Customers.Where(c => c.PhoneNumber == phoneNumber).FirstOrDefault());
     }
 }
Пример #19
0
 public List <Product> AllProducts()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Products.Where(p => p.DeleteFlag != true).ToList());
     }
 }
Пример #20
0
 public Order GetOrderWithDetailsByOrderId(int oId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Orders.Include(o => o.Customer).Include(o => o.OrderDetails.Select(d => d.Product)).Include(o => o.OrderDetails.Select(d => d.Size)).Where(o => o.OrderID == oId).FirstOrDefault());
     }
 }
Пример #21
0
 public IEnumerable <Category> AllCategories()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.Where(c => c.DeleteFlag != true).ToList());
     }
 }
Пример #22
0
 public bool DoesSizeExist(string sizeCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Sizes.Any(s => s.SizeCode == sizeCode));
     }
 }
Пример #23
0
 public IEnumerable <Category> AllCategories()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.ToList());
     }
 }
Пример #24
0
 public void CreateOrder(Order o)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Orders.Add(o);
         ctx.SaveChanges();
     }
 }
Пример #25
0
 public void AddCustomer(Customer c)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Customers.Add(c);
         ctx.SaveChanges();
     }
 }
Пример #26
0
 public void AddMessageURL(Message m)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Messages.Add(m);
         ctx.SaveChanges();
     }
 }
Пример #27
0
 public int ProductSizeStock(int pId, int sId)
 {
     using (var ctx = new BirovAmContext())
     {
         var ps = ctx.ProductsSizes.Where(p => p.ProductID == pId && p.SizeID == sId).FirstOrDefault();
         return(ps.Stock);
     }
 }
Пример #28
0
 public List <Order> GetAllOrders()
 {
     using (var ctx = new BirovAmContext())
     {
         var date = new DateTime(2016, 5, 20);
         return(ctx.Orders.Include(o => o.Customer).Include(o => o.OrderDetails.Select(d => d.Product)).Include(o => o.OrderDetails.Select(d => d.Size)).Where(o => o.DeleteFlag != true && o.OrderDate > date).ToList());
     }
 }
Пример #29
0
 public bool OutOfStock(int pId, int sId, int qty)
 {
     using (var ctx = new BirovAmContext())
     {
         ProductsSize ps = ctx.ProductsSizes.Where(p => p.ProductID == pId && p.SizeID == sId).FirstOrDefault();
         return(ps.Stock - qty <= 5);
     }
 }
Пример #30
0
 public decimal GettotalAmountOwed(int oId)
 {
     using (var ctx = new BirovAmContext())
     {
         var order = ctx.Orders.Where(o => o.OrderID == oId).FirstOrDefault();
         return(order.TotalCost.Value - order.TotalAmountPaid.Value);
     }
 }