/// <summary> /// Executes an order. /// </summary> /// <param name="order">The order to execute.</param> private void ExecuteOrder(Order order) { var appSvc = new ApplicationServices(); Type teamAppSvcType = appSvc.GetType(); MethodInfo theMethod = teamAppSvcType.GetMethod(order.OrderType.OrderTypeValue.ToString()); theMethod.Invoke(appSvc, new object[] { order.Parameters }); }
/// <summary> /// Drops an order. /// </summary> /// <param name="order">The order to drop.</param> public void DropOrder(Order order) { var orderRepo = this.container.Resolve<IOrderRepository>(); var uow = this.container.Resolve<IUnitOfWork>(); orderRepo.Delete(order); uow.Commit(); }
/// <summary> /// Updates an order. /// </summary> /// <param name="order">The order to update.</param> public void UpdateOrder(Order order) { OrderingServices orderingSvc = new OrderingServices(); int lastingHours = order.OrderType.TimeToProcess - Convert.ToInt32((DateTime.Now - order.DateTime).TotalMinutes); if (lastingHours <= 0) { // Execute order & drop it this.ExecuteOrder(order); orderingSvc.DropOrder(order); } else { orderingSvc.UpdateLastingHours(order, lastingHours); } }
/// <summary> /// Places a team order. /// </summary> /// <param name="theTeam">The team which made the order.</param> /// <param name="orderTypeValue">The order type.</param> /// <param name="parameters">The parameters of the order.</param> public void PlaceTeamOrder(Team theTeam, EOrderType orderTypeValue, string parameters) { var orderTypeRepo = this.container.Resolve<IOrderTypeRepository>(); OrderType orderType = orderTypeRepo.GetByOrderTypeValue(orderTypeValue); var uow = this.container.Resolve<IUnitOfWork>(); Order order = new Order() { Team = theTeam, OrderType = orderType, Parameters = parameters, DateTime = DateTime.Now, CountdownToProcess = orderType.TimeToProcess }; orderRepo.Save(order); uow.Commit(); }
/// <summary> /// Updates the order lasting hours. /// </summary> /// <param name="order">The order to update.</param> /// <param name="lastingHours">The lasting hours.</param> public void UpdateLastingHours(Order order, int lastingHours) { var orderRepo = this.container.Resolve<IOrderRepository>(); var uow = this.container.Resolve<IUnitOfWork>(); order.CountdownToProcess = lastingHours; orderRepo.Update(order); uow.Commit(); }