public static Customers GetCustomerFromId(int id) { using (var db = new MVPOnBoardAPIContext()) { return(db.Customers.Find(id)); } }
public static Products GetProductFromId(int id) { using (var db = new MVPOnBoardAPIContext()) { return(db.Products.Find(id)); } }
public static Sales GetSaleFromId(int id) { using (var db = new MVPOnBoardAPIContext()) { return(db.Sales.Find(id)); } }
//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 } }
public static void CreateCustomerInfo(Customers cust) { using (var db = new MVPOnBoardAPIContext()) { db.Customers.Add(cust); db.SaveChanges(); } }
public static void UpdateCustomerInfoFromId(Customers cust) { using (var db = new MVPOnBoardAPIContext()) { db.Entry(cust).State = EntityState.Modified; db.SaveChanges(); } }
public static void UpdateSaleInfoFromId(Sales sale) { using (var db = new MVPOnBoardAPIContext()) { db.Entry(sale).State = EntityState.Modified; db.SaveChanges(); } }
public static void CreateProductInfo(Products prod) { using (var db = new MVPOnBoardAPIContext()) { db.Products.Add(prod); db.SaveChanges(); } }
public static void DeleteProductInfoFromId(int id) { using (var db = new MVPOnBoardAPIContext()) { db.Products.Remove(ProductDAL.GetProductFromId(id)); db.SaveChanges(); } }
public static void DeleteSaleInfoFromId(int id) { using (var db = new MVPOnBoardAPIContext()) { db.Sales.Remove(SaleDAL.GetSaleFromId(id)); db.SaveChanges(); } }
public static void UpdateProductInfoFromId(Products prod) { using (var db = new MVPOnBoardAPIContext()) { db.Entry(prod).State = EntityState.Modified; db.SaveChanges(); } }
public static void CreateSaleInfo(Sales sale) { using (var db = new MVPOnBoardAPIContext()) { db.Sales.Add(sale); db.SaveChanges(); } }
//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); } }
//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); } }
//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 } }
//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 } }
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(); } }