{ public void Addstore(Stores store) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; using (var context = new DamionBuyContext(options)) { var newstore = new Store() { StoreName = "DamionBuy", StoreLocationAddress = store.StoreLocationAddress, StoreLocationCity = store.StoreLocationCity, StoreLocationState = store.StoreLocationState, StoreLocationCountry = store.StoreLocationCountry, StoreLocationZip = store.StoreLocationZip, StorePhoneNumber = store.StorePhoneNumber, }; context.Add(newstore); context.SaveChanges(); } }
public void AddCustomer(User customer) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; using (var context = new DamionBuyContext(options)) { var newCustomer = new Member() { FirstName = customer.FirstName, LastName = customer.LastName, Role = customer.Role, Email = customer.Email, CustomerLocationAddress = customer.CustomerLocationAddress, CustomerLocationCity = customer.CustomerLocationCity, CustomerLocationState = customer.CustomerLocationState, CustomerLocationCountry = customer.CustomerLocationCountry, CustomerLocationZip = customer.CustomerLocationZIP, Password = customer.Password }; context.Add(newCustomer); context.SaveChanges(); }; }
public User TestSignIn(string EmailAdresstest, string Passwordtest) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; User memberFound = new User(); using (var context = new DamionBuyContext(options)) { Member query = context.Members.Where(x => x.Email.Equals(EmailAdresstest)).First(); if (query == null) { memberFound = null; } else { if (query.Password != Passwordtest) { memberFound = null; } else { memberFound.FirstName = query.FirstName; memberFound.LastName = query.LastName; memberFound.Email = query.Email; memberFound.Password = query.Password; memberFound.CustomerLocationAddress = query.CustomerLocationAddress; memberFound.CustomerLocationCity = query.CustomerLocationCity; memberFound.CustomerLocationState = query.CustomerLocationState; memberFound.CustomerLocationCountry = query.CustomerLocationCountry; memberFound.CustomerLocationZIP = query.CustomerLocationZip; memberFound.Role = query.Role; } } } return(memberFound); }
public void placeorder(Orders order) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; using (var context = new DamionBuyContext(options)) { var newOrder = new Order() { CustomerId = order.CustomerNumber, StoreId = order.StoreID, DatePlaced = DateTime.Now, }; context.Add(newOrder); context.SaveChanges(); Order dbOrderV2 = context.Orders.OrderBy(x => x.Id).Last(); List <OrderItem> orderDetailList = new List <OrderItem>(); List <OrderItem> newdetail = new List <OrderItem>(); foreach (var product in order.Product) { OrderItem neworderdetail = new OrderItem { Orderid = dbOrderV2.Id, Productid = product.ID, Quantity = product.Quantity }; orderDetailList.Add(neworderdetail); } foreach (var i in orderDetailList) { context.Add(i); context.SaveChanges(); } }; }
Stores IStoreRepository.Findstore(string ZipC) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; using (var context = new DamionBuyContext(options)) { Stores newfoundstore = new Stores(); Store query = context.Stores.Where(x => x.StorePhoneNumber.Equals(ZipC)).First(); if (query == null) { newfoundstore = null; } else { newfoundstore.StoreLocationAddress = query.StoreLocationAddress; newfoundstore.StoreLocationCity = query.StoreLocationCity; newfoundstore.StoreLocationState = query.StoreLocationState; newfoundstore.StoreLocationCountry = query.StoreLocationCountry; newfoundstore.StoreLocationZip = query.StoreLocationCountry; newfoundstore.StorePhoneNumber = query.StorePhoneNumber; } return(newfoundstore); } }
public void addProduct(Products newproduct) { string connectionString = File.ReadAllText("C:/Revature/databaseconnectionstring.txt"); var options = new DbContextOptionsBuilder <DamionBuyContext>() .UseSqlServer(connectionString) .Options; using (var context = new DamionBuyContext(options)) { var newproduc = new Product() { ProductName = newproduct.ProductName, ProductPrice = newproduct.ProductPrice, ProductDescription = newproduct.ProductDescription }; context.Add(newproduc); context.SaveChanges(); } }