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 rooms = _roomStorage.GetFullList(); var list = new List(); foreach (var dinner in dinners) { var record = new ReportMealPlanDinnerViewModel { DinnerName = dinner.DinnerName, MealPlans = new List>() }; foreach (var room in rooms) { if (room.RoomDinners.ContainsKey(dinner.Id)) { foreach (var mealPlan in mealPlans) { if (mealPlan.MealPlanRooms.ContainsKey(room.Id)) { record.MealPlans.Add(new Tuple(mealPlan.MealPlanName, mealPlan.MealPlanPrice)); } } } } 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) }); } } }