public StockReportBuilder()
 {
     stockData = new StockDataStructure()
     {
         Warehouses = new Dictionary <string, WarehouseStock>(),
         Materials  = new Dictionary <string, string>()
     };
 }
        private List <ReportSection> GenerateOrderedReportSections(StockDataStructure stockDataStructure)
        {
            List <ReportSection> sections = new List <ReportSection>();

            foreach (var w in stockDataStructure.Warehouses)
            {
                sections.Add(new ReportSection {
                    Name = w.Key, Total = w.Value.materials.Sum(x => x.Value), Materials = w.Value.materials
                });
            }

            return(sections.OrderByDescending(x => x.Total).ThenByDescending(x => x.Name).ToList());
        }
        public string Generate(StockDataStructure stockDataStructure)
        {
            StringBuilder sb = new StringBuilder();


            if (stockDataStructure == null || stockDataStructure.Warehouses == null)
            {
                return(sb.ToString());
            }

            List <ReportSection> sections = GenerateOrderedReportSections(stockDataStructure);

            foreach (var s in sections)
            {
                if (sb.Length > 0)
                {
                    sb.AppendLine();
                }
                AddWarehouseHeader(sb, s);
                AddWarehouseMaterials(sb, s);
            }

            return(sb.ToString().Trim());
        }