public static string GetStatus(Order.State state) { switch (state) { case Order.State.Active: return("active"); case Order.State.Cancelled: return("cancelled"); default: throw new Exception("Unknown order state"); } }
public List <Order> getOrders(Order.State state) { Console.WriteLine("getOrders(state) called."); List <Order> res = new List <Order>(); foreach (Order order in orders) { if (order.StateProperty.Equals(state)) { res.Add(order); } } return(res); }
public List <Order> getOrdersByTable(int tableId, Order.State state) { Console.WriteLine("getOrdersByTable(state,tableId) called."); List <Order> res = new List <Order>(); foreach (Order order in orders) { if (order.TableId == tableId && order.StateProperty.Equals(state)) { res.Add(order); } } return(res); }
public List <Order> getOrdersByType(Order.State state, Product.Type type) { Console.WriteLine("getOrdersByType(state,type) called."); List <Order> res = new List <Order>(); foreach (Order order in orders) { if (order.StateProperty.Equals(state) && type.Equals(order.Product.TypeProperty)) { res.Add(order); } } return(res); }
public void changeOrderStatus(Guid orderId, Order.State newStatus) { Order norder = null; bool istableDone = true; int tableId = 0; foreach (Order it in orders) { if (it.Id == orderId) { it.StateProperty = newStatus; norder = it; tableId = norder.TableId; break; } } NotifyClients(Operation.Changed_Order_State, norder, tableId); foreach (Order it in orders) { if (it.TableId == tableId && !it.StateProperty.Equals(Order.State.DELIVERED) && !it.StateProperty.Equals(Order.State.CLOSED)) { istableDone = false; break; } } if (istableDone == true) { Table table = tables.Find(t => t.Id.Equals(tableId)); if (table != null && !table.StateProperty.Equals(Table.State.DONE)) { table.StateProperty = Table.State.DONE; NotifyClients(Operation.Changed_Table_State, null, tableId); } } else if (istableDone != true) { Table table = tables.Find(t => t.Id.Equals(tableId)); if (table != null && !table.StateProperty.Equals(Table.State.WAITING)) { table.StateProperty = Table.State.WAITING; NotifyClients(Operation.Changed_Table_State, null, tableId); } } }
private string stateToString(Order.State state) { switch (state.type) { case Order.State.Type.WAITING: return("Waiting Expedition"); case Order.State.Type.DISPATCHED_AT: return("Dispatched at " + state.dispatchDate.ToString("MM/dd/yyyy")); case Order.State.Type.DISPATCH_OCCURS_AT: return("Dispatch will occur at " + state.dispatchDate.ToString("MM/dd/yyyy")); default: return(""); } }
public MobileBuilder WithOrderState(Order.State withOrderState) { orderState = withOrderState; return(this); }