119 lines
4.6 KiB
C#
119 lines
4.6 KiB
C#
|
using HotelBusinessLogic.OfficePackage.HelperModels;
|
|||
|
using HotelBusinessLogic.OfficePackage;
|
|||
|
using HotelContracts.BindingModels;
|
|||
|
using HotelContracts.SearchModels;
|
|||
|
using HotelContracts.StoragesContracts;
|
|||
|
using HotelContracts.ViewModels;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using HotelContracts.BusinessLogicsContracts;
|
|||
|
|
|||
|
namespace HotelBusinessLogic.BusinessLogics
|
|||
|
{
|
|||
|
public class ReportLogicHeadwaiter : IReportHeadwaiterLogic
|
|||
|
{
|
|||
|
private readonly IRoomStorage _roomStorage;
|
|||
|
private readonly IDinnerStorage _dinnerStorage;
|
|||
|
private readonly IMealPlanStorage _mealPlansStorage;
|
|||
|
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
|||
|
private readonly AbstractSaveToExcelHeadwaiter _saveToExcel;
|
|||
|
private readonly AbstractSaveToWordHeadwaitre _saveToWord;
|
|||
|
private readonly AbstractSaveToPdfHeadwaiter _saveToPdf;
|
|||
|
public ReportLogicHeadwaiter(IRoomStorage roomStorage, IDinnerStorage dinnerStorage, IMealPlanStorage mealPlansStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf)
|
|||
|
{
|
|||
|
_roomStorage = roomStorage;
|
|||
|
_dinnerStorage = dinnerStorage;
|
|||
|
_mealPlansStorage = mealPlansStorage;
|
|||
|
_conferenceBookingStorage = conferenceBookingStorage;
|
|||
|
_saveToExcel = saveToExcel;
|
|||
|
_saveToWord = saveToWord;
|
|||
|
_saveToPdf = saveToPdf;
|
|||
|
}
|
|||
|
public List<ReportMealPlanDinnerViewModel> GetMealPlanDinner()
|
|||
|
{
|
|||
|
var mealPlans = _mealPlansStorage.GetFullList();
|
|||
|
var dinners = _dinnerStorage.GetFullList();
|
|||
|
var list = new List<ReportMealPlanDinnerViewModel>();
|
|||
|
foreach (var dinner in dinners)
|
|||
|
{
|
|||
|
var record = new ReportMealPlanDinnerViewModel
|
|||
|
{
|
|||
|
DinnerName = dinner.DinnerName,
|
|||
|
MealPlans = new List<Tuple<string, DateTime>>()
|
|||
|
};
|
|||
|
foreach (var mealPlan in mealPlans)
|
|||
|
{
|
|||
|
if (mealPlan.MealPlanDinners.ContainsKey(dinner.Id))
|
|||
|
{
|
|||
|
record.MealPlans.Add(new Tuple<string, DateTime>(mealPlans.MealPlanName, mealPlans.StartDate));
|
|||
|
}
|
|||
|
}
|
|||
|
list.Add(record);
|
|||
|
}
|
|||
|
return list;
|
|||
|
}
|
|||
|
|
|||
|
public List<ReportConferenceBindingRoomsViewModel> GetConferenceBindingRooms(ReportHeadwaiterBindingModel model)
|
|||
|
{
|
|||
|
var listAll = new List<ReportConferenceBindingRoomsViewModel>();
|
|||
|
|
|||
|
var listConferenceBinding = _conferenceBookingStorage.GetFilteredList(new ConferenceBookingSearchModel
|
|||
|
{
|
|||
|
HeadwaiterId = model.HeadwaiterId,
|
|||
|
DateFrom = model.DateFrom,
|
|||
|
DateTo = model.DateTo
|
|||
|
});
|
|||
|
|
|||
|
var listRooms = _roomStorage.GetFilteredList(new RoomSearchModel());
|
|||
|
|
|||
|
foreach (var room in listRooms)
|
|||
|
{
|
|||
|
listAll.Add(new ReportConferenceBindingRoomsViewModel
|
|||
|
{
|
|||
|
RoomName = room.RoomName,
|
|||
|
RoomPrice = room.RoomPrice,
|
|||
|
RoomFrame = room.RoomFrame
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return listAll;
|
|||
|
}
|
|||
|
|
|||
|
public void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model)
|
|||
|
{
|
|||
|
_saveToExcel.CreateReport(new ExcelInfoHeadwaiter
|
|||
|
{
|
|||
|
FileName = model.FileName,
|
|||
|
Title = "Список изделий",
|
|||
|
MealPlanDinner = GetMealPlanDinner()
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model)
|
|||
|
{
|
|||
|
_saveToWord.CreateDoc(new WordInfoHeadwaiter
|
|||
|
{
|
|||
|
FileName = model.FileName,
|
|||
|
Title = "Список участников",
|
|||
|
MealPlanDinner = GetMealPlanDinner()
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model)
|
|||
|
{
|
|||
|
_saveToPdf.CreateDoc(new PdfInfoHeadwaiter
|
|||
|
{
|
|||
|
FileName = model.FileName,
|
|||
|
Title = "Список участников",
|
|||
|
DateFrom = model.DateFrom!.Value,
|
|||
|
DateTo = model.DateTo!.Value,
|
|||
|
ConferenceBindingRooms = GetConferenceBindingRooms(model)
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|