public static void ReportsInParallel(BaseWareHouse target) { Parallel.Invoke(async() => { await GetSortedProducts(target); await GetUniqueProducts(target); await GetGreatestNumberProducts(target); }); }
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); }
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); }
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); }
static async void ExecuteAsync(BaseWareHouse wareHouse, WareHouseAddCommand command, string type) { if (type.Equals("add")) { await wareHouse.ResponsibleEmployee.SetCommand(command); } else { await wareHouse.ResponsibleEmployee.ExecuteCommand(); } }
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}")); } }
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; }