diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs b/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs index 7a1ea61..60c7ed3 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs @@ -5,6 +5,8 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.StoragesContracts; using HotelContracts.ViewModels; +using HotelDataBaseImplement; +using HotelDataBaseImplement.Models; namespace HotelBusinessLogic.BusinessLogics { @@ -66,34 +68,41 @@ namespace HotelBusinessLogic.BusinessLogics var listAll = new List<ReportMembersViewModel>(); var listСonferences = _conferenceStorage.GetFilteredList(new ConferenceSearchModel - { - OrganiserId = model.OrganiserId, - DateFrom = model.DateFrom, - DateTo = model.DateTo + { + OrganiserId = model.OrganiserId, + DateFrom = model.DateFrom, + DateTo = model.DateTo }); foreach (var conference in listСonferences) { - foreach (var c in conference.ConferenceMembers) + foreach (var m in conference.ConferenceMembers.Values) { listAll.Add(new ReportMembersViewModel { StartDate = conference.StartDate, ConferenceName = conference.ConferenceName, - MemberFIO=c.Value.MemberFIO + MemberFIO = m.MemberFIO }); } } - var listMealPlans = _mealPlanStorage.GetFilteredList(new MealPlanSearchModel()); + + var listMealPlans = _mealPlanStorage.GetFilteredList(new MealPlanSearchModel + { + OrganiserId = model.OrganiserId, + }); foreach (var mealPlan in listMealPlans) { - listAll.Add(new ReportMembersViewModel + foreach (var mp in mealPlan.MealPlanMembers.Values) { - MealPlanName = mealPlan.MealPlanName, - MealPlanPrice = mealPlan.MealPlanPrice - }); - + listAll.Add(new ReportMembersViewModel + { + MemberFIO = mp.MemberFIO, + MealPlanName = mealPlan.MealPlanName, + MealPlanPrice = mealPlan.MealPlanPrice + }); + } } return listAll; diff --git a/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj b/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj index e2290cd..37edc34 100644 --- a/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj +++ b/Hotel/HotelBusinessLogic/HotelBusinessLogic.csproj @@ -14,6 +14,7 @@ <ItemGroup> <ProjectReference Include="..\HotelContracts\HotelContracts.csproj" /> + <ProjectReference Include="..\HotelDataBaseImplement\HotelDataBaseImplement.csproj" /> </ItemGroup> </Project> diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfOrganiser.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfOrganiser.cs index 760168c..4fd3871 100644 --- a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfOrganiser.cs +++ b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfOrganiser.cs @@ -20,7 +20,7 @@ namespace HotelBusinessLogic.OfficePackage Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" }); + CreateTable(new List<string> { "4cm", "5cm", "3cm", "4cm", "2cm" }); CreateRow(new PdfRowParameters { Texts = new List<string> { "ФИО участника", "Название конференции", "Дата начала конференции", "Название плана питания", "Стоимость плана питания" }, @@ -31,7 +31,7 @@ namespace HotelBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List<string> { member.Id.ToString(), member.ConferenceName, member.StartDate.ToShortDateString(), member.MealPlanName, member.MealPlanPrice.ToString() }, + Texts = new List<string> { member.MemberFIO, member.ConferenceName, member.StartDate.ToShortDateString(), member.MealPlanName, member.MealPlanPrice.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/Hotel/HotelContracts/SearchModels/MealPlanSearchModel.cs b/Hotel/HotelContracts/SearchModels/MealPlanSearchModel.cs index 0c4cfbc..b47565f 100644 --- a/Hotel/HotelContracts/SearchModels/MealPlanSearchModel.cs +++ b/Hotel/HotelContracts/SearchModels/MealPlanSearchModel.cs @@ -4,6 +4,8 @@ { public int? Id { get; set; } public string? MealPlanName { get; set; } - public int? OrganiserId { get; set; } + public int? OrganiserId { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs index a4b513d..c9d1dd2 100644 --- a/Hotel/HotelOrganiserApp/Controllers/HomeController.cs +++ b/Hotel/HotelOrganiserApp/Controllers/HomeController.cs @@ -19,6 +19,36 @@ namespace HotelOrganiserApp.Controllers /*--------------------Reports------------------------*/ + [HttpGet] + public IActionResult ListMembersToPdfFile() + { + if (APIClient.Organiser == null) + { + return Redirect("~/Home/Enter"); + } + + return View(); + } + + [HttpPost] + public void ListMembersToPdfFile(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Organiser == null) + { + throw new Exception("Не авторизованы"); + } + + APIClient.PostRequest("api/Report/CreateReportToPdfFile", new ReportBindingModel() + { + DateFrom = dateFrom, + DateTo = dateTo, + OrganiserId=APIClient.Organiser.Id + }); + + Response.Redirect("ListMembersToPdfFile"); + } + + [HttpGet] public IActionResult ListMemberConferenceToFile() { diff --git a/Hotel/HotelOrganiserApp/Views/Home/ListMembersToPdfFile.cshtml b/Hotel/HotelOrganiserApp/Views/Home/ListMembersToPdfFile.cshtml new file mode 100644 index 0000000..875e97c --- /dev/null +++ b/Hotel/HotelOrganiserApp/Views/Home/ListMembersToPdfFile.cshtml @@ -0,0 +1,38 @@ +@{ + ViewData["Title"] = "ListMembersToPdf"; +} + +<head> + <link rel="stylesheet" href="~/css/listmembers.css" asp-append-version="true" /> +</head> + +<div class="text-center"> + <h2 + class="u-text u-text-custom-color-1 u-text-default u-text-1" + > + Создание отчета по участникам за период + </h2> +</div> + +<form method="post"> + <div class="u-form-group u-form-name u-label-top"> + <label class="u-label u-text-custom-color-1 u-label-1">Дата начала периода:</label> + <input + type="datetime-local" + placeholder="Выберите дату начала периода" + id="dateFrom" name="dateFrom" + class="u-input u-input-rectangle"/> + </div> + <div class="u-form-email u-form-group u-label-top"> + <label class="u-label u-text-custom-color-1 u-label-2">Дата конца периода:</label> + <input + type="datetime-local" + placeholder="Выберите дату конца периода" + id="dateTo" name="dateTo" + class="u-input u-input-rectangle"/> + </div> + <div class="u-align-right u-form-group u-form-submit u-label-top"> + <div class="col-8"></div> + <div class="col-4"><input type="submit" value="Сформировать отчёт" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div> + </div> +</form> \ No newline at end of file diff --git a/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml b/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml index 41cf465..3df455e 100644 --- a/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml +++ b/Hotel/HotelOrganiserApp/Views/Shared/_Layout.cshtml @@ -69,7 +69,7 @@ <li class="u-nav-item"> <a class="u-button-style u-custom-color-4 u-nav-link u-text-active-custom-color-2 u-text-custom-color-1 u-text-hover-custom-color-6" - asp-area="" asp-controller="Home" asp-action="ListMembers" + asp-area="" asp-controller="Home" asp-action="ListMembersToPdfFile" >Список участников (pdf)</a> </li> <li class="u-nav-item"> @@ -142,7 +142,7 @@ class="u-h-spacing-20 u-nav u-unstyled u-v-spacing-10" > <li class="u-nav-item"> - <a class="u-button-style u-nav-link" asp-area="" asp-controller="Home" asp-action="ListMembers" + <a class="u-button-style u-nav-link" asp-area="" asp-controller="Home" asp-action="ListMembersToPdfFile" >Список участников (pdf)</a> </li> <li class="u-nav-item"> diff --git a/Hotel/HotelRestApi/Controllers/ReportController.cs b/Hotel/HotelRestApi/Controllers/ReportController.cs index 027d18e..9819c6c 100644 --- a/Hotel/HotelRestApi/Controllers/ReportController.cs +++ b/Hotel/HotelRestApi/Controllers/ReportController.cs @@ -17,6 +17,26 @@ namespace HotelRestApi.Controllers _reportOrganiserLogic = reportOrganiserLogic; } + [HttpPost] + public void CreateReportToPdfFile(ReportBindingModel model) + { + try + { + _reportOrganiserLogic.SaveMembersToPdfFile(new ReportBindingModel + { + FileName="Отчет PDF.pdf", + DateFrom = model.DateFrom, + DateTo = model.DateTo, + OrganiserId=model.OrganiserId, + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + [HttpPost] public void CreateReportToWordFile(ReportBindingModel model) { @@ -30,6 +50,7 @@ namespace HotelRestApi.Controllers throw; } } + [HttpPost] public void CreateReportToExcelFile(ReportBindingModel model) { diff --git a/Hotel/HotelRestApi/Отчет PDF.pdf b/Hotel/HotelRestApi/Отчет PDF.pdf new file mode 100644 index 0000000..f75cc5a Binary files /dev/null and b/Hotel/HotelRestApi/Отчет PDF.pdf differ