public List <Message> AllMessages() { using (var ctx = new BirovAmContext()) { return(ctx.Messages.ToList()); } }
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()); } }
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()); } }
public Customer GetCustomerById(int custId) { using (var ctx = new BirovAmContext()) { return(ctx.Customers.Where(c => c.CustomerID == custId).FirstOrDefault()); } }
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()); } }
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(); } } }
public Size SizeById(int id) { using (var ctx = new BirovAmContext()) { return(ctx.Sizes.Include(s => s.Categories).Where(s => s.SizeID == id).FirstOrDefault()); } }
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()); } }
public Category CategoryById(int id) { using (var ctx = new BirovAmContext()) { return(ctx.Categories.Where(c => c.CategoryID == id).FirstOrDefault()); } }
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()); } }
public List <PaymentRecord> PaymentRecordsForOrder(int oId) { using (var ctx = new BirovAmContext()) { return(ctx.PaymentRecords.Where(p => p.OrderID == oId).ToList()); } }
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)); } }
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()); } }
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()); } }
public Product FindProductByItemCode(string itemCode) { using (var ctx = new BirovAmContext()) { return(ctx.Products.Where(p => p.ProductCode == itemCode).FirstOrDefault()); } }
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()); } }
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()); } }
public Customer FindCustomerByPhoneNumber(string phoneNumber) { using (var ctx = new BirovAmContext()) { return(ctx.Customers.Where(c => c.PhoneNumber == phoneNumber).FirstOrDefault()); } }
public List <Product> AllProducts() { using (var ctx = new BirovAmContext()) { return(ctx.Products.Where(p => p.DeleteFlag != true).ToList()); } }
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()); } }
public IEnumerable <Category> AllCategories() { using (var ctx = new BirovAmContext()) { return(ctx.Categories.Where(c => c.DeleteFlag != true).ToList()); } }
public bool DoesSizeExist(string sizeCode) { using (var ctx = new BirovAmContext()) { return(ctx.Sizes.Any(s => s.SizeCode == sizeCode)); } }
public IEnumerable <Category> AllCategories() { using (var ctx = new BirovAmContext()) { return(ctx.Categories.ToList()); } }
public void CreateOrder(Order o) { using (var ctx = new BirovAmContext()) { ctx.Orders.Add(o); ctx.SaveChanges(); } }
public void AddCustomer(Customer c) { using (var ctx = new BirovAmContext()) { ctx.Customers.Add(c); ctx.SaveChanges(); } }
public void AddMessageURL(Message m) { using (var ctx = new BirovAmContext()) { ctx.Messages.Add(m); ctx.SaveChanges(); } }
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); } }
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()); } }
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); } }
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); } }