Exemple #1
0
 public static void ReportsInParallel(BaseWareHouse target)
 {
     Parallel.Invoke(async() => {
         await GetSortedProducts(target);
         await GetUniqueProducts(target);
         await GetGreatestNumberProducts(target);
     });
 }
Exemple #2
0
        public static async Task <List <BaseProduct> > GetGreatestNumberProducts(BaseWareHouse target)
        {
            List <BaseProduct> greatestNumberProducts = new List <BaseProduct>();
            await Task.Run(() => {
                greatestNumberProducts = target.ProductList.OrderByDescending(pl => pl.Quantity).Take(3).ToList();
            });

            return(greatestNumberProducts);
        }
Exemple #3
0
        public static async Task <List <BaseProduct> > GetUniqueProducts(BaseWareHouse target)
        {
            List <BaseProduct> uniqueProducts = new List <BaseProduct>();
            await Task.Run(() => {
                uniqueProducts = target.ProductList.Distinct().ToList();
            });

            return(uniqueProducts);
        }
Exemple #4
0
        public static async Task <List <BaseProduct> > GetSortedProducts(BaseWareHouse target)
        {
            List <BaseProduct> sortedProducts = new List <BaseProduct>();
            await Task.Run(() => {
                sortedProducts = target.ProductList.Where(pl => pl.Quantity < 3).OrderBy(d => d.Quantity).ToList();
            });

            return(sortedProducts);
        }
Exemple #5
0
 static async void ExecuteAsync(BaseWareHouse wareHouse, WareHouseAddCommand command, string type)
 {
     if (type.Equals("add"))
     {
         await wareHouse.ResponsibleEmployee.SetCommand(command);
     }
     else
     {
         await wareHouse.ResponsibleEmployee.ExecuteCommand();
     }
 }
Exemple #6
0
 public static void CreateCSV(BaseWareHouse wareHouse, string fileName)
 {
     FilePath = $"{_folderpath}{fileName}.csv";
     CheckForFolderExist();
     CheckForFileExist();
     using (StreamWriter writer = new StreamWriter(new FileStream(FilePath, FileMode.Open, FileAccess.Write)))
     {
         writer.WriteLine("Name, SKU, Description, Price, Quantity");
         wareHouse.ProductList.ForEach(pl => writer.WriteLine($"{pl.Name}, {pl.SKU}, {pl.Description}, {pl.Price}, {pl.Quantity}"));
     }
 }
Exemple #7
0
 public static void DisplayErrorMessage(BaseWareHouse sender, WareHouseEventArgs wareHouseEventArgs)
 {
     Console.WriteLine($"{DateTime.Now} | You can't add {wareHouseEventArgs.Product.Name} into {sender.GetType()} ! Event type: {wareHouseEventArgs.EventType}");
 }
 public WareHouseAddCommand(BaseWareHouse receiver, BaseProduct productToAdd, Employee eventReceiver)
 {
     Receiver      = receiver;
     ProductToAdd  = productToAdd;
     EventReceiver = eventReceiver;
 }