Exemplo n.º 1
0
 public List <Message> AllMessages()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Messages.ToList());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 4
0
 public Customer GetCustomerById(int custId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Customers.Where(c => c.CustomerID == custId).FirstOrDefault());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 9
0
 public Category CategoryById(int id)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.Where(c => c.CategoryID == id).FirstOrDefault());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 11
0
 public List <PaymentRecord> PaymentRecordsForOrder(int oId)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.PaymentRecords.Where(p => p.OrderID == oId).ToList());
     }
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 15
0
 public Product FindProductByItemCode(string itemCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Products.Where(p => p.ProductCode == itemCode).FirstOrDefault());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 18
0
 public Customer FindCustomerByPhoneNumber(string phoneNumber)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Customers.Where(c => c.PhoneNumber == phoneNumber).FirstOrDefault());
     }
 }
Exemplo n.º 19
0
 public List <Product> AllProducts()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Products.Where(p => p.DeleteFlag != true).ToList());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 21
0
 public IEnumerable <Category> AllCategories()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.Where(c => c.DeleteFlag != true).ToList());
     }
 }
Exemplo n.º 22
0
 public bool DoesSizeExist(string sizeCode)
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Sizes.Any(s => s.SizeCode == sizeCode));
     }
 }
Exemplo n.º 23
0
 public IEnumerable <Category> AllCategories()
 {
     using (var ctx = new BirovAmContext())
     {
         return(ctx.Categories.ToList());
     }
 }
Exemplo n.º 24
0
 public void CreateOrder(Order o)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Orders.Add(o);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 25
0
 public void AddCustomer(Customer c)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Customers.Add(c);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 26
0
 public void AddMessageURL(Message m)
 {
     using (var ctx = new BirovAmContext())
     {
         ctx.Messages.Add(m);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }