private static void SalesReportTest()
        {
            FakeOrdersService   ordersService = new FakeOrdersService();
            IEnumerable <Order> orders        = ordersService.Get();

            SalesReport salesReport = new SalesReport();


            // Header
            salesReport.Title            = "Raport sprzedaży";
            salesReport.CreateDate       = DateTime.Now;
            salesReport.TotalSalesAmount = orders.Sum(s => s.Amount);


            // By Gender
            salesReport.GenderDetails = orders
                                        .GroupBy(o => o.Customer.Gender)
                                        .Select(g => new GenderReportDetail(
                                                    g.Key,
                                                    g.Sum(x => x.Details.Sum(d => d.Quantity)),
                                                    g.Sum(x => x.Details.Sum(d => d.LineTotal))));

            // By Product
            salesReport.ProductDetails = orders
                                         .SelectMany(o => o.Details)
                                         .GroupBy(o => o.Product)
                                         .Select(g => new ProductReportDetail(g.Key, g.Sum(p => p.Quantity), g.Sum(p => p.LineTotal)));

            Console.WriteLine(salesReport);
        }
        private static void SalesReportBuilderFluentTest()
        {
            FakeOrdersService   ordersService      = new FakeOrdersService();
            IEnumerable <Order> orders             = ordersService.Get();
            ISalesReportBuilder salesReportBuilder = new SalesReportBuilder(orders);

            //salesReportBuilder
            //    .AddHeader()
            //    .AddSectionByGender()
            //    .AddSectionByProduct()
            //    .Build();
        }
Beispiel #3
0
        private static void SalesReportTest()
        {
            FakeOrdersService   ordersService = new FakeOrdersService();
            IEnumerable <Order> orders        = ordersService.Get();

            ISalesReportBuilder salesReportBuilder = new MySalesReportBuilder(orders);

            salesReportBuilder.AddHeader("Raport sprzedaży");
            salesReportBuilder.AddSectionByGender();
            salesReportBuilder.AddSectionByProduct();

            SalesReport salesReport = salesReportBuilder.Build();

            Console.WriteLine(salesReport);
        }
        private static void SalesReportBuilderTest()
        {
            FakeOrdersService   ordersService = new FakeOrdersService();
            IEnumerable <Order> orders        = ordersService.Get();

            ISalesReportBuilder salesReportBuilder = new SalesReportBuilder(orders);

            salesReportBuilder.AddHeader();
            salesReportBuilder.AddGenderTotals();

            if (true)
            {
                salesReportBuilder.AddProductTotals();
            }

            SalesReportBase salesReport = salesReportBuilder.Build();

            Console.WriteLine(salesReport);
        }
Beispiel #5
0
        private static void SalesReportTest()
        {
            FakeOrdersService   ordersService = new FakeOrdersService();
            IEnumerable <Order> orders        = ordersService.Get();

            ISalesReportBuilder salesReportBuilder = new SalesReportBuilder(orders);

            salesReportBuilder.AddHeader();

            if (true)
            {
                salesReportBuilder.AddSectionByGender();
            }


            salesReportBuilder.AddSectionByProduct();

            SalesReport salesReport = salesReportBuilder.Build();


            //SalesReport salesReport = new SalesReport();
            //salesReport.Title = "Raport sprzedaży";
            //salesReport.CreateDate = DateTime.Now;
            //salesReport.TotalSalesAmount = orders.Sum(s => s.Amount);

            //salesReport.GenderDetails = orders
            //    .GroupBy(o => o.Customer.Gender)
            //    .Select(g => new GenderReportDetail(
            //                g.Key,
            //                g.Sum(x => x.Details.Sum(d => d.Quantity)),
            //                g.Sum(x => x.Details.Sum(d => d.LineTotal))));

            //salesReport.ProductDetails = orders
            //    .SelectMany(o => o.Details)
            //    .GroupBy(o => o.Product)
            //    .Select(g => new ProductReportDetail(g.Key, g.Sum(p => p.Quantity), g.Sum(p => p.LineTotal)));

            Console.WriteLine(salesReport);
        }
Beispiel #6
0
        private static void SalesReportTest()
        {
            bool hasSectionByGender = true;

            FakeOrdersService   ordersService = new FakeOrdersService();
            IEnumerable <Order> orders        = ordersService.Get();

            ISalesReportBuilder salesReportBuilder = new MySalesReportBuilder(orders);

            salesReportBuilder.AddHeader();

            if (hasSectionByGender)
            {
                salesReportBuilder.AddSectionByGender();
            }

            salesReportBuilder.AddSectionByProduct();

            SalesReport salesReport = salesReportBuilder.Build();

            Console.WriteLine(salesReport);
        }