2024-03-24 13:51:15 +04:00
|
|
|
|
using HotelBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using HotelBusinessLogic.OfficePackage;
|
|
|
|
|
using HotelContracts.BindingModels;
|
|
|
|
|
using HotelContracts.BusinessLogicsContracts;
|
|
|
|
|
using HotelContracts.SearchModels;
|
|
|
|
|
using HotelContracts.StoragesContracts;
|
|
|
|
|
using HotelContracts.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace HotelBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
public class ReportLogicHeadwaiter : IReportHeadwaiterLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IRoomStorage _roomStorage;
|
|
|
|
|
private readonly ILunchStorage _lunchStorage;
|
2024-05-03 12:24:23 +04:00
|
|
|
|
private readonly IMealPlanStorage _mealPlanStorage;
|
2024-03-24 13:51:15 +04:00
|
|
|
|
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
|
|
|
|
private readonly AbstractSaveToExcelHeadwaiter _saveToExcel;
|
|
|
|
|
private readonly AbstractSaveToWordHeadwaitre _saveToWord;
|
|
|
|
|
private readonly AbstractSaveToPdfHeadwaiter _saveToPdf;
|
|
|
|
|
|
2024-05-03 12:24:23 +04:00
|
|
|
|
public ReportLogicHeadwaiter(IRoomStorage roomStorage, ILunchStorage lunchStorage, IMealPlanStorage mealPlanStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf)
|
2024-03-24 13:51:15 +04:00
|
|
|
|
{
|
|
|
|
|
_roomStorage = roomStorage;
|
|
|
|
|
_lunchStorage = lunchStorage;
|
2024-05-03 12:24:23 +04:00
|
|
|
|
_mealPlanStorage = mealPlanStorage;
|
2024-03-24 13:51:15 +04:00
|
|
|
|
_conferenceBookingStorage = conferenceBookingStorage;
|
|
|
|
|
_saveToExcel = saveToExcel;
|
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportLunchRoomViewModel> GetLunchRoom(List<int> Ids)
|
|
|
|
|
{
|
|
|
|
|
if (Ids == null)
|
|
|
|
|
{
|
|
|
|
|
return new List<ReportLunchRoomViewModel>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rooms = _roomStorage.GetFullList();
|
2024-05-03 12:24:23 +04:00
|
|
|
|
var mealplans = _mealPlanStorage.GetFullList();
|
2024-03-24 13:51:15 +04:00
|
|
|
|
|
|
|
|
|
List<LunchViewModel> lunches = new List<LunchViewModel>();
|
|
|
|
|
foreach (var memId in Ids)
|
|
|
|
|
{
|
|
|
|
|
var res = _lunchStorage.GetElement(new LunchSearchModel { Id = memId });
|
|
|
|
|
if (res != null)
|
|
|
|
|
{
|
|
|
|
|
lunches.Add(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = new List<ReportLunchRoomViewModel>();
|
|
|
|
|
foreach (var lunch in lunches)
|
|
|
|
|
{
|
|
|
|
|
var record = new ReportLunchRoomViewModel
|
|
|
|
|
{
|
|
|
|
|
LunchName = lunch.LunchName,
|
2024-05-03 12:24:23 +04:00
|
|
|
|
MealPlans = new List<Tuple<string, double>>()
|
2024-03-24 13:51:15 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var room in rooms)
|
|
|
|
|
{
|
|
|
|
|
if (room.RoomLunches.ContainsKey(lunch.Id))
|
|
|
|
|
{
|
2024-05-03 12:24:23 +04:00
|
|
|
|
var mealPlanId = room.MealPlanId;
|
|
|
|
|
var mealPlan = mealplans.FirstOrDefault(dp => dp.Id == mealPlanId);
|
|
|
|
|
if (mealPlan != null)
|
|
|
|
|
{
|
|
|
|
|
record.MealPlans.Add(new Tuple<string, double>(mealPlan.MealPlanName, mealPlan.MealPlanPrice));
|
|
|
|
|
}
|
2024-03-24 13:51:15 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(record);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportLunchesViewModel> GetLunches(ReportHeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
var listAll = new List<ReportLunchesViewModel>();
|
|
|
|
|
|
|
|
|
|
var listRooms = _roomStorage.GetFilteredList(new RoomSearchModel
|
|
|
|
|
{
|
|
|
|
|
HeadwaiterId = model.HeadwaiterId,
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var room in listRooms)
|
|
|
|
|
{
|
|
|
|
|
foreach (var m in room.RoomLunches.Values)
|
|
|
|
|
{
|
|
|
|
|
listAll.Add(new ReportLunchesViewModel
|
|
|
|
|
{
|
|
|
|
|
RoomName = room.RoomName,
|
|
|
|
|
RoomPrice = room.RoomPrice,
|
|
|
|
|
LunchName = m.LunchName,
|
|
|
|
|
LunchPrice = m.LunchPrice
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var listConferenceBookings = _conferenceBookingStorage.GetFilteredList(new ConferenceBookingSearchModel
|
|
|
|
|
{
|
|
|
|
|
HeadwaiterId = model.HeadwaiterId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var conferenceBooking in listConferenceBookings)
|
|
|
|
|
{
|
|
|
|
|
foreach (var mp in conferenceBooking.ConferenceBookingLunches.Values)
|
|
|
|
|
{
|
|
|
|
|
listAll.Add(new ReportLunchesViewModel
|
|
|
|
|
{
|
|
|
|
|
LunchName = mp.LunchName,
|
|
|
|
|
LunchPrice = mp.LunchPrice,
|
|
|
|
|
NameHall = conferenceBooking.NameHall,
|
|
|
|
|
BookingDate = conferenceBooking.BookingDate
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return listAll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveLunchRoomToExcelFile(ReportHeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfoHeadwaiter
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список номеров",
|
|
|
|
|
LunchRooms = GetLunchRoom(model.Ids)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveLunchRoomToWordFile(ReportHeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToWord.CreateDoc(new WordInfoHeadwaiter
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список номеров",
|
|
|
|
|
LunchRooms = GetLunchRoom(model.Ids)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveLunchesToPdfFile(ReportHeadwaiterBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model.DateFrom == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Дата начала не задана");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.DateTo == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Дата окончания не задана");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_saveToPdf.CreateDoc(new PdfInfoHeadwaiter
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список обедов",
|
|
|
|
|
DateFrom = model.DateFrom!.Value,
|
|
|
|
|
DateTo = model.DateTo!.Value,
|
|
|
|
|
Lunches = GetLunches(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|