public IActionResult Create([Bind("CustomerId,FirstName,LastName,Phone,Email,Street,City,State,ZipCode,Password,UserName")] Customer customer) { if (ModelState.IsValid) { ctx.Add(customer); ctx.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public IActionResult Create([Bind("ProductId,Title,Genre,Release,Price,Quantity")] Games games) { if (ModelState.IsValid) { _context.Add(games); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(games)); }
public IActionResult Create([Bind("StoreId,StoreName,Phone,Email,Street,City,State,ZipCode")] Locations locations) { if (ModelState.IsValid) { ctx.Add(locations); ctx.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(locations)); }
public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,Phone,Email,Street,City,State,ZipCode,Password,UserName")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("StoreId,StoreName,Phone,Email,Street,City,State,ZipCode")] Locations locations) { if (ModelState.IsValid) { _context.Add(locations); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(locations)); }
public IActionResult Create([Bind("InventoryId,StoreId,ProductId,Quantity,Title")] Inventory inventory) { if (ModelState.IsValid) { _context.Add(inventory); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Games, "ProductId", "Title", inventory.ProductId); ViewData["StoreId"] = new SelectList(_context.Locations, "StoreId", "StoreName", inventory.StoreId); return(View(inventory)); }
public async Task <IActionResult> Create([Bind("ProductId,OrderId,Quantity,OrderlineId")] Orderline orderline) { if (ModelState.IsValid) { _context.Add(orderline); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", orderline.OrderId); ViewData["ProductId"] = new SelectList(_context.Games, "ProductId", "Title", orderline.ProductId); return(View(orderline)); }
public void Add(Library.Customer customer) { using Game_RealmContext ctx = new Game_RealmContext(); var C_Customer = new Model.Customer(); // add BusinessLogic Customer to DbCustomer C_Customer.FirstName = customer.firstName; C_Customer.LastName = customer.lastName; C_Customer.Password = customer.Password; C_Customer.UserName = customer.Username; ctx.Add(C_Customer); ctx.SaveChanges(); }
public void SaveStore(IDataStore store) { using Game_RealmContext context = new Game_RealmContext(); var S_Stores = new Locations(); // add BusinessLogic Store to DbStores S_Stores.StoreName = store.StoreName; S_Stores.Street = store.Street; S_Stores.City = store.City; S_Stores.State = store.State; S_Stores.ZipCode = store.Zipcode; context.Add(S_Stores); context.SaveChanges(); }
public void SaveOrder(Orders order, ICustomer customer, IDataStore store) { using Game_RealmContext context = new Game_RealmContext(); var O_Orders = new Orders(); // add BusinessLogic Order to DBOrders O_Orders.CustomerId = customer.CustomerId; O_Orders.StoreId = store.StoreId; O_Orders.Checkout = order.Checkout; O_Orders.Time = DateTime.Now; // local time context.Add(O_Orders); context.SaveChanges(); }
public IActionResult Create([Bind("LocationId,CustomerId,ProductID")] OrdersViewModel ordersV) { Game_RealmContext ctx = new Game_RealmContext(); if (ModelState.IsValid) { string orderlinesController = "Orderlines"; Orders newOrd = new Orders { CustomerId = ordersV.CustomerId, StoreId = ordersV.LocationId, Time = DateTime.Now, Checkout = 0 }; _context.Add(newOrd); _context.SaveChanges(); _context.Entry(newOrd).Reload(); Orderline ords = new Orderline { OrderId = newOrd.OrderId, ProductId = ordersV.ProductID, Quantity = 1, }; _context.Orderline.Add(ords); _context.SaveChanges(); _context.Entry(ords).Reload(); return(RedirectToAction(nameof(Create), orderlinesController)); } ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "FirstName"); ViewData["StoreId"] = new SelectList(_context.Locations, "StoreId", "StoreName"); ViewData["ProductID"] = new SelectList(_context.Games, "ProductId", "Title"); ViewData["Price"] = new SelectList(_context.Games, "Price", "Price"); return(RedirectToAction(nameof(Index))); }