예제 #1
0
        private static void WriteReportByCities(XmlTextWriter writer, DateTime startDate, DateTime endDate)
        {
            using (var context = new GirlsAgencyContext())
            {
                foreach (var city in context.Cities.ToList())
                {
                    var TotalOrdersByDate = context.Orders
                                            .Where(order => order.Girl.CityId == city.CityId &&
                                                   order.Date >= startDate && order.Date <= endDate)
                                            .OrderBy(order => order.Date)
                                            .GroupBy(order => order.Date)
                                            .Select(orderAndIncome => new
                    {
                        Date   = orderAndIncome.Key,
                        Income = orderAndIncome.Sum(order => order.Duration * order.Girl.PricePerHour)
                    })
                                            .ToList();

                    if (TotalOrdersByDate.Any())
                    {
                        writer.WriteStartElement("city");
                        writer.WriteAttributeString("name", city.Name);

                        foreach (var order in TotalOrdersByDate)
                        {
                            DisplayIncomes(writer, order.Date, order.Income);
                        }

                        writer.WriteEndElement();
                    }
                }
            }
        }
 //takes the contexts from different servers
 public RepositoryController(OracleContext oracleContext, GirlsAgencyContext girlsAgencyContext)
 {
     //this.OracleContext = oracleContext;
     //this.SqlServerContext = girlsAgencyContext;
        // this.Requester = new Requester(new List<IContext>{oracleContext, girlsAgencyContext});
     this.Requester = new Requester(girlsAgencyContext);
 }
예제 #3
0
 //takes the contexts from different servers
 public RepositoryController(OracleContext oracleContext, GirlsAgencyContext girlsAgencyContext)
 {
     //this.OracleContext = oracleContext;
     //this.SqlServerContext = girlsAgencyContext;
     // this.Requester = new Requester(new List<IContext>{oracleContext, girlsAgencyContext});
     this.Requester = new Requester(girlsAgencyContext);
 }
예제 #4
0
        private static void WriteReportByCities(XmlTextWriter writer, DateTime startDate, DateTime endDate)
        {
            using (var context = new GirlsAgencyContext())
            {
                foreach (var city in context.Cities.ToList())
                {
                    var TotalOrdersByDate = context.Orders
                        .Where(order => order.Girl.CityId == city.CityId &&
                        order.Date >= startDate && order.Date <= endDate)
                        .OrderBy(order => order.Date)
                        .GroupBy(order => order.Date)
                        .Select(orderAndIncome => new
                        {
                            Date = orderAndIncome.Key,
                            Income = orderAndIncome.Sum(order => order.Duration * order.Girl.PricePerHour)
                        })
                        .ToList();

                    if (TotalOrdersByDate.Any())
                    {
                        writer.WriteStartElement("city");
                        writer.WriteAttributeString("name", city.Name);

                        foreach (var order in TotalOrdersByDate)
                        {
                            DisplayIncomes(writer, order.Date, order.Income);
                        }

                        writer.WriteEndElement();
                    }
                }
            }
        }
예제 #5
0
        private static void ImportOrdersToDatabase(IEnumerable <Order> orders)
        {
            var sqlRepo  = new GenericRepository <Order>(new GirlsAgencyContext());
            var girlRepo = new GenericRepository <Girl>(new GirlsAgencyContext());
            var ctx      = new GirlsAgencyContext();

            foreach (var order in orders)
            {
                sqlRepo.Add(order);
                //ctx.Customers.
            }

            sqlRepo.SaveChanges();
        }
예제 #6
0
        private static void ImportOrdersToDatabase(IEnumerable<Order> orders)
        {
            var sqlRepo = new GenericRepository<Order>(new GirlsAgencyContext());
            var girlRepo = new GenericRepository<Girl>(new GirlsAgencyContext());
            var ctx = new GirlsAgencyContext();
            foreach (var order in orders)
            {
                sqlRepo.Add(order);
                //ctx.Customers.
            }

            sqlRepo.SaveChanges();
        }
예제 #7
0
        public static void ExportGirlsReport(string start, string end)
        {
            using (Document pdfReport = new Document())
            {
                var startDate = DateTime.Parse(start);
                var endDate   = DateTime.Parse(end);

                FileStream file = File.Create("../../../GirlsReport.pdf");
                PdfWriter.GetInstance(pdfReport, file);
                pdfReport.Open();

                iTextSharp.text.Image girlsImg = iTextSharp.text.Image.GetInstance("../../../girlsIcon.png");
                girlsImg.ScaleToFit(200f, 200f);

                // girlsImg.SetAbsolutePosition(pdfReport.PageSize.Width  - 100f, pdfReport.PageSize.Height - 50f );

                pdfReport.Add(girlsImg);

                //set table
                PdfPTable table = new PdfPTable(5);
                table.TotalWidth  = 550f;
                table.LockedWidth = true;
                float[] widths = new float[] { 150f, 80f, 80f, 150f, 90f };
                table.SetWidths(widths);

                PdfPCell header = new PdfPCell(new Phrase("Aggregated Girls Orders Report"))
                {
                    Colspan             = 5,
                    HorizontalAlignment = 1,
                    BackgroundColor     = new BaseColor(135, 196, 28),
                    PaddingTop          = 10f,
                    PaddingBottom       = 10f
                };

                table.AddCell(header);

                decimal grandSum = 0;

                using (var context = new GirlsAgencyContext())
                {
                    var orderDates = context.Orders
                                     .Where(o => o.Date >= startDate && o.Date <= endDate)
                                     .Select(o => o.Date)
                                     .Distinct()
                                     .ToList();

                    foreach (var date in orderDates)
                    {
                        DisplayHeaderDates(table, date);

                        var orders = context.Orders
                                     .Where(o => o.Date == date)
                                     .Select(o => new
                        {
                            GirlName = o.Girl.FirstName + " " + o.Girl.LastName,
                            o.Duration,
                            PricePerHour = o.Girl.PricePerHour,
                            Client       = o.Customer.FirstName + " " + o.Customer.LastName,
                            Sum          = o.Duration * o.Girl.PricePerHour
                        })
                                     .ToList();

                        foreach (var order in orders)
                        {
                            DisplayColumn(table, order.GirlName);
                            DisplayColumn(table, order.Duration.ToString("F2"));
                            DisplayColumn(table, order.PricePerHour.ToString("F2"));
                            DisplayColumn(table, order.Client);
                            DisplayColumn(table, order.Sum.ToString("F2"));
                        }

                        var totalDateSum = orders.Sum(o => o.Sum);
                        DisplayDateFooter(table, date, totalDateSum);

                        grandSum += totalDateSum;
                    }
                }

                DisplayGrandSumFooter(table, grandSum);

                pdfReport.Add(table);
                pdfReport.Close();
            }
        }