private static void InsertCustomers() { var customer = new Customer() { Name = "Anna1" }; var customerSet = new Customer[] { new Customer { Name = "Ivan1" }, new Customer { Name = "Pavel1" } }; using (var context = new OnlineStoreContext()) { //context.Customers.Add(customer); context.Add(customer); context.AddRange(customerSet); context.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("GroupId,NameGroup,DescriptionGroup")] GroupGoods groupGoods) { if (ModelState.IsValid) { _context.Add(groupGoods); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(groupGoods)); }
public async Task <IActionResult> Create([Bind("CourierId,LastNameCour,FirstNameCour,PatronymicCour,PositionCour,FullInfoAboutCourier")] Courier courier) { if (ModelState.IsValid) { _context.Add(courier); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(courier)); }
public async Task <IActionResult> Create([Bind("GoodsId,NameGoods,GroupId,ManufacturerGoods,DescriptionGoods,Photos,Price,OfferDate,StockAvailability")] Goods goods) { if (ModelState.IsValid) { _context.Add(goods); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GroupId"] = new SelectList(_context.GroupGoods, "GroupId", "GroupId", goods.GroupId); return(View(goods)); }
public async Task <IActionResult> Create([Bind("CommentsId,BasketId,CustomersId,Comments,Marks,Reason,ReturnDate")] CommentsAboutWork commentsAboutWork) { if (ModelState.IsValid) { _context.Add(commentsAboutWork); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BasketId"] = new SelectList(_context.Basket, "BasketId", "BasketId", commentsAboutWork.BasketId); ViewData["CustomersId"] = new SelectList(_context.Customers, "CustomersId", "CustomersId", commentsAboutWork.CustomersId); return(View(commentsAboutWork)); }
public async Task <IActionResult> Create([Bind("BasketId,GoodsId,OrderDate,CompleteDate,ImplementationOrder,EmployeeId,CourierId,CustomersId")] Basket basket) { if (ModelState.IsValid) { _context.Add(basket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourierId"] = new SelectList(_context.Courier, "CourierId", "CourierId", basket.CourierId); ViewData["CustomersId"] = new SelectList(_context.Customers, "CustomersId", "CustomersId", basket.CustomersId); ViewData["EmployeeId"] = new SelectList(_context.Employee, "EmployeeId", "EmployeeId", basket.EmployeeId); ViewData["GoodsId"] = new SelectList(_context.Goods, "GoodsId", "GoodsId", basket.GoodsId); return(View(basket)); }
private static void InsertCustomers() { var customer = new Customer { Name = "Mikhail2" }; //_context.Add(customer); //var customerSet = new Customer[] //{ // new Customer { Name = "Nikolay" }, // new Customer {Name = "Vladislav"} //}; using (var context = new OnlineStoreContext()) { //context.Customers.Add(customer); context.Add(customer); //context.AddRange(customerSet); //context.SaveChanges(); } }
private static void InsertProducts() { var product = new Product { Name = "iPhone XsMax", Price = 119990 }; var products = new Product[] { new Product { Name = "Samsung A8", Price = 69990 }, new Product { Name = "Sony XperiaZ", Price = 59990 } }; using (var context = new OnlineStoreContext()) { context.Add(product); context.AddRange(products); context.SaveChanges(); } }
private static void InsertProduct() { var product = new Product { Name = "apple", Price = 30 }; var productSet = new Product[] { new Product { Name = "tomato", Price = 25 }, new Product { Name = "orange", Price = 65 } }; using (var context = new OnlineStoreContext()) { context.Add(product); context.AddRange(productSet); context.SaveChanges(); } }
public void Register(Customer customer) { customer.IsTheAccountActive = true; database.Add(customer); database.SaveChanges(); }
public void Register(Product product) { database.Add(product); database.SaveChanges(); }
public void Add(Product product) { _onlineStoreContext.Add(product); _onlineStoreContext.SaveChanges(); }