diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicHeadwaiter.cs b/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicHeadwaiter.cs new file mode 100644 index 0000000..4c0128a --- /dev/null +++ b/Hotel/HotelBusinessLogic/BusinessLogics/ReportLogicHeadwaiter.cs @@ -0,0 +1,118 @@ +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 GetMealPlanDinner() + { + var mealPlans = _mealPlansStorage.GetFullList(); + var dinners = _dinnerStorage.GetFullList(); + var list = new List(); + foreach (var dinner in dinners) + { + var record = new ReportMealPlanDinnerViewModel + { + DinnerName = dinner.DinnerName, + MealPlans = new List>() + }; + foreach (var mealPlan in mealPlans) + { + if (mealPlan.MealPlanDinners.ContainsKey(dinner.Id)) + { + record.MealPlans.Add(new Tuple(mealPlans.MealPlanName, mealPlans.StartDate)); + } + } + list.Add(record); + } + return list; + } + + public List GetConferenceBindingRooms(ReportHeadwaiterBindingModel model) + { + var listAll = new List(); + + 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) + }); + } + } +} diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaiter.cs similarity index 100% rename from Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs rename to Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaiter.cs diff --git a/Hotel/HotelContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs b/Hotel/HotelContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs new file mode 100644 index 0000000..0e8bf74 --- /dev/null +++ b/Hotel/HotelContracts/BindingModels/ReportHeadwaiterBindingModel.cs.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HotelContracts.BindingModels +{ + public class ReportHeadwaiterBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + public int HeadwaiterId { get; set; } + } +} diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs new file mode 100644 index 0000000..7e0f69a --- /dev/null +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IReportHeadwaiterLogic.cs @@ -0,0 +1,19 @@ +using HotelContracts.BindingModels; +using HotelContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HotelContracts.BusinessLogicsContracts +{ + public interface IReportHeadwaiterLogic + { + List GetMealPlanDinner(); + List GetConferenceBindingRooms(ReportHeadwaiterBindingModel model); + void SaveMealPlanDinnerToWordFile(ReportHeadwaiterBindingModel model); + void SaveMealPlanDinnerToExcelFile(ReportHeadwaiterBindingModel model); + void SaveConferenceBindingRoomsToPdfFile(ReportHeadwaiterBindingModel model); + } +}