public async Task <ApiResult <PagedResult <OrdersDto> > > GetOrdersPagingAsync(int pageIndex, int pageSize) { var orders = await(from o in _context.Orders join customer in _context.Customers on o.CustomerId equals customer.Id into CustomersGroup from c in CustomersGroup.DefaultIfEmpty() join employee in _context.Employees on o.EmployeeId equals employee.Id into EmployeesGroup from e in EmployeesGroup.DefaultIfEmpty() join ps in _context.PaymentStatuses on o.PaymentStatusId equals ps.Id join ts in _context.TransactionStatuses on o.TransactionStatusId equals ts.Id orderby o.DateCreated descending where o.TransactionStatusId != GlobalProperties.WaitingTransactionId let hasPaid = _context.ReceiptVouchers.Where(x => x.OrderId == o.Id).Sum(x => x.Received) select new OrdersDto() { OrderId = o.Id, CustomerName = string.IsNullOrEmpty(c.Name)?o.CustomerName:c.Name, EmployeeName = e.Name, DateCreated = o.DateCreated, PaymentStatusName = ps.Name, TransactionStatusName = ts.Name, CustomerHasPaid = o.TotalAmount }).GetPagedAsync(pageIndex, pageSize); return(new ApiResult <PagedResult <OrdersDto> >(HttpStatusCode.OK, orders)); }
private void GetCustomersGroup(ContentProviderConfig contentProvider, CustomersGroup customersGroup) { customersGroup.Customers = contentProvider.MediaServicesSets.Select(mediaServicesSet => new Customer { Id = mediaServicesSet.Name,// TODO is there an actual ID value we can use instead of the name of hte account for the Customer ID? Name = mediaServicesSet.Name }).ToList(); Parallel.ForEach(customersGroup.Customers, (customer) => { var mediaServicesSet = contentProvider.MediaServicesSets.First(m => m.Name == customer.Name); GetCustomer(customer, mediaServicesSet); }); }
public void ExecuteScenario(int scenarioId) { List <ActionsListBusiness> actionsList = actionsListService.GetByScenario(scenarioId); string[] nextAction = null; CustomersGroup customers = null; int tableNumber = 0; string actualScenarioAction = null; string[] actualScenarioActionParam = null; do { actualScenarioAction = GetNextScenarioAction(ref actionsList, ref nextAction); actualScenarioActionParam = GetNextScenarioActionParam(ref nextAction); Console.WriteLine(actualScenarioAction); switch (actualScenarioAction) { case "CreationReservation": customers = new CustomersGroup( CreateCustomersGroup(int.Parse(actualScenarioActionParam[1].Split('=')[1]), int.Parse(actualScenarioActionParam[2].Split('=')[1]), int.Parse(actualScenarioActionParam[3].Split('=')[1])), true); DateTime reservationDate = new DateTime(SimulationTimeOfServiceStart.Year, SimulationTimeOfServiceStart.Month, SimulationTimeOfServiceStart.Day, 18 /*int.Parse(actualScenarioActionParam[0].Split('h')[0])*/, 0, 0); lock (model.DiningRoom.Butler.lockObj) { tableNumber = model.DiningRoom.Butler.CreateBooking(customers, reservationDate); } break; case "ArriveeClientsReservation": model.DiningRoom.Reception.BookedCustomersArrive(customers); lock (model.DiningRoom.Butler.lockObj) { //tableNumber = model.DiningRoom.Butler.FindTable(customers); ThreadSyncByTableNumber.Add(tableNumber, new AutoResetEvent(false)); } break; case "ArriveeClientsNonReserve": customers = new CustomersGroup( CreateCustomersGroup(int.Parse(actualScenarioActionParam[0].Split('=')[1]), int.Parse(actualScenarioActionParam[1].Split('=')[1]), int.Parse(actualScenarioActionParam[2].Split('=')[1])), true); //model.DiningRoom.Reception.BookedCustomersArrive(customers); lock (model.DiningRoom.Butler.lockObj) { tableNumber = model.DiningRoom.Butler.FindTable(customers); ThreadSyncByTableNumber.Add(tableNumber, new AutoResetEvent(false)); } break; case "AmenerClientsATable": HeadWaiter headWaiter = null; do { headWaiter = model.DiningRoom.HeadWaiters.FirstOrDefault(x => x.IsBusy == false); } while (headWaiter == null); lock (headWaiter.lockObj) { headWaiter.PlaceCustomersAtTable(customers, tableNumber); } break; case "PrendreLesCommandes": headWaiter = null; do { headWaiter = model.DiningRoom.HeadWaiters.FirstOrDefault(x => x.IsBusy == false); } while (headWaiter == null); lock (headWaiter.lockObj) { headWaiter.TakeOrders(tableNumber); } break; case "PreparationDesCommandes": lock (model.Kitchen.HeadChef.lockObj) { model.Kitchen.HeadChef.StartCoursesOrderPreparation(model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber)); } break; case "AmenerPlatsEnSalle": ThreadSyncByTableNumber.First(x => x.Key == tableNumber).Value.WaitOne(); break; case "ClientsMangent": int i = 0; Thread[] eatingCustomersThreads = new Thread[model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).ServedFood.Count]; foreach (Customer customer in model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).SeatedCustomers) { if (i >= model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).ServedFood.Count) { break; } int j = i; eatingCustomersThreads[i] = new Thread(delegate() { lock (customer.lockObj) { customer.EatFood(model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).ServedFood[j]); } }); eatingCustomersThreads[i].Start(); i++; } for (int y = 0; y < eatingCustomersThreads.Length; y++) { if (eatingCustomersThreads[y] != null) { eatingCustomersThreads[y].Join(); } } break; case "DebarasserTable": Waiter waiter = null; //while (model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).ServedFood.TrueForAll(x => x.IsFinished)) { } do { waiter = model.DiningRoom.Waiters.FirstOrDefault(x => x.IsBusy == false); } while (waiter == null); lock (waiter.lockObj) { waiter.ClearPlates(tableNumber); } break; case "ClientsPartent": waiter = null; do { waiter = model.DiningRoom.Waiters.FirstOrDefault(x => x.IsBusy == false); } while (waiter == null); lock (waiter.lockObj) { model.DiningRoom.Countertop.Orders.Remove(model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber)); model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).SeatedCustomers.Clear(); model.DiningRoom.Tables.Find(x => x.TableNumber == tableNumber).NextCourseToServe = CourseType.Starter; model.DiningRoom.Waiters.Find(x => x.IsBusy == false).ClearAndCleanTable(tableNumber); } break; default: break; } } while (actualScenarioAction != "ClientsPartent"); }