2023-04-07 11:09:51 +04:00
|
|
|
|
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();
|
2023-04-07 13:49:59 +04:00
|
|
|
|
var rooms = _roomStorage.GetFullList();
|
2023-04-07 11:09:51 +04:00
|
|
|
|
var list = new List<ReportMealPlanDinnerViewModel>();
|
|
|
|
|
foreach (var dinner in dinners)
|
|
|
|
|
{
|
|
|
|
|
var record = new ReportMealPlanDinnerViewModel
|
|
|
|
|
{
|
|
|
|
|
DinnerName = dinner.DinnerName,
|
2023-04-07 13:49:59 +04:00
|
|
|
|
MealPlans = new List<Tuple<string, double>>()
|
2023-04-07 11:09:51 +04:00
|
|
|
|
};
|
2023-04-07 13:49:59 +04:00
|
|
|
|
foreach (var room in rooms)
|
2023-04-07 11:09:51 +04:00
|
|
|
|
{
|
2023-04-07 13:49:59 +04:00
|
|
|
|
if (room.RoomDinners.ContainsKey(dinner.Id))
|
2023-04-07 11:09:51 +04:00
|
|
|
|
{
|
2023-04-07 13:49:59 +04:00
|
|
|
|
foreach (var mealPlan in mealPlans)
|
|
|
|
|
{
|
|
|
|
|
if (mealPlan.MealPlanRooms.ContainsKey(room.Id))
|
|
|
|
|
{
|
|
|
|
|
record.MealPlans.Add(new Tuple<string, double>(mealPlan.MealPlanName, mealPlan.MealPlanPrice));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-07 11:09:51 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|