public static void AddOrder(Domain.OrdersManager newOrder) { PizzaEntities db = new PizzaEntities(); var order = ConvertOrderToEntity(newOrder); db.Orders.Add(order); db.SaveChanges(); }
public static Order ConvertOrderToEntity(Domain.OrdersManager newOrder) { var order = new Order(); order.Id = newOrder.Id; order.Size = newOrder.Pizza.Size; order.Crust = newOrder.Pizza.Crust; order.Sausage = newOrder.Pizza.Sausage; order.Pepperoni = newOrder.Pizza.Pepperoni; order.Onions = newOrder.Pizza.Onions; order.GreenPeppers = newOrder.Pizza.GreenPeppers; order.Total = newOrder.Pizza.Total; order.Name = newOrder.Delivery.Name; order.Address = newOrder.Delivery.Address; order.Zip = newOrder.Delivery.Zip; order.Phone = newOrder.Delivery.Phone; order.PaymentMethod = newOrder.Delivery.PaymentMethod; order.Complete = newOrder.Complete; return(order); }
// create a new delivery public Domain.OrdersManager PlaceOrder() { var newOrder = new Domain.OrdersManager(); newOrder.Id = Guid.NewGuid(); newOrder.Pizza = UpdateTotal(); newOrder.Delivery = new Domain.Delivery(); newOrder.Delivery.Name = nameTextBox.Text; newOrder.Delivery.Address = addressTextBox.Text; newOrder.Delivery.Zip = zipTextBox.Text; newOrder.Delivery.Phone = phoneTextBox.Text; if (cashRadioButton.Checked) { newOrder.Delivery.PaymentMethod = Domain.PaymentMethod.Cash; } else if (creditRadioButton.Checked) { newOrder.Delivery.PaymentMethod = Domain.PaymentMethod.Credit; } newOrder.Complete = false; return(newOrder); }
public static void SaveOrder(Domain.OrdersManager Order) { DAL.OrdersRepository.AddOrder(Order); }