public ActionResult Create(ClassLibrary.Models.Customer customer) { if (ModelState.IsValid) { _customerRepo.InsertCustomer(customer); return(RedirectToAction("Index")); } return(View(customer)); }
//public List<ClassLibrary.Order> GetCustomerOrders(int customerId) //{ // using var context = new Project0DBContext(_contextOptions); // var dbCustomerOrders = context.Orders.Where(o => o.CustomerId == customerId).ToList(); // var appCustomerOrders = dbCustomerOrders.Select(o => new ClassLibrary.Order() // { // OrderId = o.OrderId, // CustomerId = o.CustomerId, // LocationId = o.LocationId, // OrderTime = o.OrderTime, // Quantity = o.Quantity // } // ).ToList(); // return appCustomerOrders; //} public void InsertCustomer(ClassLibrary.Models.Customer customer) { using var context = new Project0DBContext(_contextOptions); var dbCustomer = new Customer() { FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email }; context.Customers.Add(dbCustomer); context.SaveChanges(); }