public ActionResult Register(RegisterViewModel model) { var address = new Address { AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, City = model.City, State = model.State, Zip = model.Zip }; _context.Address.Add(address); var customer = new Customer { Address = address.AddressId, Name = model.Name, Email = model.Email, Phone = "9856875555" }; _context.Customer.Add(customer); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public IActionResult SizeAndToppingPick() { var order = new Order { CustomerId = GetLoggedInUser().CustomerId, EmployeeId = 2, DeliveryStatus = 2 }; _context.Order.Add(order); SetOrder(order); var toppingInfo = new List <ToppingInfo>(); for (int i = 2; i <= 4; i++) { var top = _context.ToppingInfo.Where(t => t.Id == i).SingleOrDefault(); toppingInfo.Add(top); } foreach (var top in toppingInfo) { var topping = new Toppings { OrderId = order.OrderId, ToppingId = top.Id }; _context.Toppings.Add(topping); } //var toppings = _context.Toppings.Where(t => t.OrderId == order.OrderId).ToList(); //foreach (var topping in toppings) //{ // order.Toppings.Add(topping); //} //_context.Update(order); _context.SaveChanges(); return(RedirectToAction("MakeAPayment")); }