示例#1
0
 public static Customers GetCustomerFromId(int id)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         return(db.Customers.Find(id));
     }
 }
示例#2
0
 public static Products GetProductFromId(int id)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         return(db.Products.Find(id));
     }
 }
示例#3
0
 public static Sales GetSaleFromId(int id)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         return(db.Sales.Find(id));
     }
 }
示例#4
0
        //this method will get all the student record

        public static Global GetFullRecordObject()
        {
            using (var db = new MVPOnBoardAPIContext())
            {
                var globalRecords = new Global();
                var sale          = db.Sales;
                var salesCust     = sale.Include(record => record.Customer).AsNoTracking();
                var salesProd     = salesCust.Include(record => record.Product);
                var salesStore    = salesProd.Include(record => record.Store);
                globalRecords.Sale = salesStore.ToArray();

                var customer     = db.Customers;
                var customerSale = customer.Include(record => record.Sales).ToArray();
                globalRecords.Customer = customerSale;

                var product     = db.Products;
                var productSale = product.Include(record => record.Sales).ToArray();
                globalRecords.Product = productSale;

                var store     = db.Stores;
                var storeSale = store.Include(record => record.Sales).ToArray();
                globalRecords.Store = storeSale;

                return(globalRecords);// or some other simple query
            }
        }
示例#5
0
 public static void CreateCustomerInfo(Customers cust)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Customers.Add(cust);
         db.SaveChanges();
     }
 }
示例#6
0
 public static void UpdateCustomerInfoFromId(Customers cust)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Entry(cust).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#7
0
 public static void UpdateSaleInfoFromId(Sales sale)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Entry(sale).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#8
0
 public static void CreateProductInfo(Products prod)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Products.Add(prod);
         db.SaveChanges();
     }
 }
示例#9
0
 public static void DeleteProductInfoFromId(int id)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Products.Remove(ProductDAL.GetProductFromId(id));
         db.SaveChanges();
     }
 }
示例#10
0
 public static void DeleteSaleInfoFromId(int id)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Sales.Remove(SaleDAL.GetSaleFromId(id));
         db.SaveChanges();
     }
 }
示例#11
0
 public static void UpdateProductInfoFromId(Products prod)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Entry(prod).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#12
0
 public static void CreateSaleInfo(Sales sale)
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         db.Sales.Add(sale);
         db.SaveChanges();
     }
 }
示例#13
0
 //this method will get all the student record
 public static IEnumerable <Customers> GetAllCustomers()
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         var customer     = db.Customers;
         var customerSale = customer.Include(record => record.Sales).ToArray();
         return(customerSale);
     }
 }
示例#14
0
 //this method will get all the student record
 public static IEnumerable <Products> GetAllProducts()
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         var product     = db.Products;
         var productSale = product.Include(record => record.Sales).ToArray();
         return(productSale);
     }
 }
示例#15
0
 //this method will get all the student record
 public static IEnumerable <Stores> GetAllStores()
 {
     using (var db = new MVPOnBoardAPIContext())
     {
         var store     = db.Stores;
         var storeSale = store.Include(record => record.Sales).ToArray();
         return(storeSale);
         //return db.Stores.ToArray(); // or some other simple query
     }
 }
示例#16
0
        //this method will get all the student record

        public static IEnumerable <Sales> GetAllSales()
        {
            using (var db = new MVPOnBoardAPIContext())
            {
                var sale        = db.Sales;
                var salesCust   = sale.Include(record => record.Customer).AsNoTracking();
                var salesProd   = salesCust.Include(record => record.Product);
                var salesStore  = salesProd.Include(record => record.Store);
                var finalResult = salesStore.ToArray();
                return(finalResult);// or some other simple query
            }
        }
示例#17
0
        public static void DeleteCustomerInfoFromId(int id)
        {
            using (var db = new MVPOnBoardAPIContext())
            {
                //var getSales = db.Sales.Where(record => record.CustomerId == id).ToArray();

                //foreach (var item in getSales)
                //{
                //    item.CustomerId = 0;
                //}
                //db.SaveChanges();
                _ = db.Customers.Remove(CustomerDAL.GetCustomerFromId(id));
                db.SaveChanges();
            }
        }