public CreateNewOrderViewModel(CreateNewOrder createNewOrder) { this.createNewOrder = createNewOrder; Service s = new Service(); AllMenuList = s.GetAllMenu().ToList(); AllOrderItemList = s.GetAllOrderItem().ToList(); AllOrderList = s.GetAllOrder().ToList(); try { using (PizzaRestoranEntities context = new PizzaRestoranEntities()) { tblOrder tblOrder = new tblOrder(); DateTime dateTime = DateTime.Now; tblOrder.DateTimeOrder = dateTime; tblOrder.Guest = LoggedGuest.id; tblOrder.OrderStatus = 1; tblOrder.TotalPrice = 0; tblOrder.Archived = 0; context.tblOrders.Add(tblOrder); context.SaveChanges(); } AllOrderList = s.GetAllOrder().ToList(); OrderList = s.GetOrder(AllOrderList.LastOrDefault().OrderID).ToList(); } catch (Exception) { } }
/// <summary> /// A method for creating a new order /// </summary> private void CreateOrderExecute() { CreateNewOrder createNewOrder = new CreateNewOrder(); createNewOrder.ShowDialog(); Service s = new Service(); if ((createNewOrder.DataContext as CreateNewOrderViewModel).IsUpdateItem == true) { string jmbg = LoggedGuest.jmbg; List <vwOrder> orderList = s.GetWaitingOrder(jmbg); if (orderList.Count < 1) { createOrder.gridWaiting.Visibility = Visibility.Collapsed; } else { createOrder.gridWaiting.Visibility = Visibility.Visible; } RefreshViewList(); } }