частичная реализация работы с пдф
This commit is contained in:
parent
cdbf09470c
commit
aa861fc0ca
@ -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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HotelContracts\HotelContracts.csproj" />
|
||||
<ProjectReference Include="..\HotelDataBaseImplement\HotelDataBaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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>
|
@ -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">
|
||||
|
@ -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)
|
||||
{
|
||||
|
BIN
Hotel/HotelRestApi/Отчет PDF.pdf
Normal file
BIN
Hotel/HotelRestApi/Отчет PDF.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user