public List <Order> CheckOrders(DateTime date, ProductTypeRepository repoPr) { List <Order> ordersOfThisDate = new List <Order>(); foreach (Order ord in listOfOrders.Values) { if (date.ToString("yyyy-MM-dd") == ord.Date.ToString("yyyy-MM-dd")) { if (repoPr.CheckAmountOfProductsInOrder(ord) == true) { ordersOfThisDate.Add(ord); OnOrderReadyToPackEventArgs args = new OnOrderReadyToPackEventArgs(); string email = BuildEmailReadyToPackOrder(ord, repoPr); args.EmailMessage = email; if (orderReadyToPack != null) { orderReadyToPack(this, args); } } else { string email = BuildEmailNotEnoughStock(ord, repoPr); OnAmountNotEnoughEventArgs args = new OnAmountNotEnoughEventArgs(); args.EmailMessage = email; if (orderAmountNotEnough != null) { orderAmountNotEnough(this, args); } } } } return(ordersOfThisDate); }
public void SendEmailForPackedOrder(object o, OnOrderIsPackedEventArgs args) { if (productTypeRepository.CheckAmountOfProductsInOrder((Order)o) == true) { productTypeRepository.RemoveProductsFromOrder(args.ListOfOrderLines); } }
public List <Order> CheckOrders(DateTime date, ProductTypeRepository repoPr) { List <Order> ordersOfThisDate = new List <Order>(); foreach (Order ord in listOfOrders.Values) { if (date.ToString("yyyy-MM-dd") == ord.Date.ToString("yyyy-MM-dd")) { if (repoPr.CheckAmountOfProductsInOrder(ord) == true) { ordersOfThisDate.Add(ord); } else { string email = BuildEmail(ord, repoPr); } } } return(ordersOfThisDate); }