Merge branch 'CourseWork' of http://student.git.athene.tech/AnnZhimol/CourseWork_Hotel into CourseWork
This commit is contained in:
commit
98352f0c47
124
Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs
Normal file
124
Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicOrganiser.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using HotelBusinessLogic.OfficePackage;
|
||||
using HotelBusinessLogic.OfficePackage.HelperModels;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using System.Reflection;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogicOrganiser : IReportOrganiserLogic
|
||||
{
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
private readonly IMemberStorage _memberStorage;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
private readonly AbstractSaveToExcelOrganiser _saveToExcel;
|
||||
private readonly AbstractSaveToWordOrganiser _saveToWord;
|
||||
private readonly AbstractSaveToPdfOrganiser _saveToPdf;
|
||||
public ReportLogicOrganiser(IMealPlanStorage mealPlanStorage, IMemberStorage memberStorage, IConferenceStorage conferenceStorage, AbstractSaveToExcelOrganiser saveToExcel, AbstractSaveToWordOrganiser saveToWord, AbstractSaveToPdfOrganiser saveToPdf)
|
||||
{
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
_memberStorage = memberStorage;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
public List<ReportMemberConferenceViewModel> GetMemberConference()
|
||||
{
|
||||
var conferences = _conferenceStorage.GetFullList();
|
||||
var members = _memberStorage.GetFullList();
|
||||
var list = new List<ReportMemberConferenceViewModel>();
|
||||
foreach (var member in members)
|
||||
{
|
||||
var record = new ReportMemberConferenceViewModel
|
||||
{
|
||||
MemberFIO = member.MemberFIO,
|
||||
Conferences = new List<Tuple<string, DateTime>>()
|
||||
};
|
||||
foreach (var conference in conferences)
|
||||
{
|
||||
if (conference.ConferenceMembers.ContainsKey(member.Id))
|
||||
{
|
||||
record.Conferences.Add(new Tuple<string, DateTime>(conference.ConferenceName, conference.StartDate));
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportMembersViewModel> GetMembers(ReportBindingModel model)
|
||||
{
|
||||
var listAll = new List<ReportMembersViewModel>();
|
||||
|
||||
var listСonferences = _conferenceStorage.GetFilteredList(new ConferenceSearchModel
|
||||
{
|
||||
OrganiserId = model.OrganiserId,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
foreach (var conference in listСonferences)
|
||||
{
|
||||
foreach (var c in conference.ConferenceMembers)
|
||||
{
|
||||
listAll.Add(new ReportMembersViewModel
|
||||
{
|
||||
StartDate = conference.StartDate,
|
||||
ConferenceName = conference.ConferenceName,
|
||||
MemberFIO=c.Value.MemberFIO
|
||||
});
|
||||
}
|
||||
}
|
||||
var listMealPlans = _mealPlanStorage.GetFilteredList(new MealPlanSearchModel());
|
||||
|
||||
foreach (var mealPlan in listMealPlans)
|
||||
{
|
||||
listAll.Add(new ReportMembersViewModel
|
||||
{
|
||||
MealPlanName = mealPlan.MealPlanName,
|
||||
MealPlanPrice = mealPlan.MealPlanPrice
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return listAll;
|
||||
}
|
||||
|
||||
public void SaveMemberConferenceToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoOrganiser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
MemberConferences = GetMemberConference()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveMemberConferenceToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfoOrganiser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
MemberConferences = GetMemberConference()
|
||||
}) ;
|
||||
}
|
||||
|
||||
public void SaveMembersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoOrganiser
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список участников",
|
||||
DateFrom = model.DateFrom!.Value,
|
||||
DateTo = model.DateTo!.Value,
|
||||
Members = GetMembers(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -5,5 +5,6 @@
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int OrganiserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user