示例#1
0
        private static async Task PrintMainPageContent(HttpContext httpContext)
        {
            using (var context = new PhotoStudioContext())
            {
                var query = context.Orders
                            .Join(context.Clients, orders => orders.ClientId, clients => clients.Id,
                                  (o, c) => new
                {
                    OptionId   = o.OptionId,
                    Name       = c.Name,
                    Surname    = c.Surname,
                    Quantity   = o.Quantity,
                    DateStart  = o.DateStart,
                    DateFinish = o.DateFinish,
                    Id         = c.Id
                })

                            .Join(context.Options, c => c.OptionId, o => o.Id, (c, o) => new
                {
                    Option     = o.Title,
                    Name       = c.Name,
                    Surname    = c.Surname,
                    Quantity   = c.Quantity,
                    DateStart  = c.DateStart,
                    DateFinish = c.DateFinish,
                    Price      = c.Quantity * o.Price,
                    Id         = c.Id
                })
                            .ToList()
                            .GroupBy(table => new { table.Surname, table.Name, table.Id });

                await httpContext.Response.WriteAsync("<div class=\"row\"><div class=\"col-4\"><div class=\"list-group\" id=\"list-tab\" role=\"tablist\">");

                foreach (var client in query)
                {
                    await httpContext.Response.WriteAsync($"<a class=\"list-group-item list-group-item-action\"  id=\"list-{client.Key.Id}-list\"" +
                                                          $"data-toggle=\"list\" href=\"#list-{client.Key.Id}\" role=\"tab\"" +
                                                          $"aria-controls=\"{client.Key.Id}\">{client.Key.Name} {client.Key.Surname}</a>");
                }
                await httpContext.Response.WriteAsync("</div></div ><div class=\"col-8\"><div class=\"tab-content\" id=\"nav-tabContent\">");

                foreach (var client in query)
                {
                    await httpContext.Response.WriteAsync($"<div class=\"tab-pane fade\" id=\"list-{client.Key.Id}\" role=\"tabpanel\"" +
                                                          $"aria-labelledby=\"list -{client.Key.Id}-list\"><table class=\"table table-striped table-dark\">" +
                                                          "<thead><tr><th>Назва послуги</th><th>Дата замовлення </th><th> Дата виконанння </th><th>Ціна </th> </tr></thead><tbody>");

                    foreach (var option in client)
                    {
                        await httpContext.Response.WriteAsync($"<tr><td>{ option.Option} </td ><td>{option.DateStart.ToShortDateString()}" +
                                                              $"</td> <td> {option.DateFinish.ToShortDateString()}</td><td>{ decimal.Round(option.Price, 2)}</td> </tr> ");
                    }
                    await httpContext.Response.WriteAsync($"<tr align=\"center\"><td colspan=\"4\">Загальна кількість замовлень: {client.Count()}</td></tr></tbody>" +
                                                          "</table></div>");
                }

                await httpContext.Response.WriteAsync("</div></div></div>");
            }
        }
示例#2
0
 private static async Task PrintOptionsPage(HttpContext httpContext)
 {
     string[] columns = { "Назва", "Опис", "Ціна" };
     using (var context = new PhotoStudioContext())
     {
         await PrintTable(httpContext, context.Options.ToList <IPrintableToHtmlRow>(), columns);
     }
 }
示例#3
0
 private static async Task PrintClientsPage(HttpContext httpContext)
 {
     string[] columns = { "Ім'я", "Прізвище", "По-батькові", "Адреса", "Номер телефону" };
     using (var context = new PhotoStudioContext())
     {
         await PrintTable(httpContext, context.Clients.ToList <IPrintableToHtmlRow>(), columns);
     }
 }