public List <RoomInfo> GetRoomInfosRevised(string[] roomTypes, DateTime startDate, DateTime endDate, CenResParamsDTO cenResParams) { List <RoomInfo> roomInfos = GetRoomInfos(roomTypes, startDate, endDate, cenResParams); IList <EUpgradeRequestDTO> eUpgradeRequests = getConfirmedRequests(); foreach (EUpgradeRequestDTO e in eUpgradeRequests) { roomInfos.FindAll(ri => ri.RoomType == e.BookedRoomType && ri.Date.Date >= e.StartDate.Value.Date && ri.Date.Date < e.EndDate.Value.Date).ForEach(ri => ri.AvailableRooms -= 1); roomInfos.FindAll(ri => ri.RoomType == e.UpgradeRoomType && ri.Date.Date >= e.StartDate.Value.Date && ri.Date.Date < e.EndDate.Value.Date).ForEach(ri => ri.AvailableRooms += 1); } return(roomInfos); }
public List <RoomInfo> GetRoomInfos(string[] roomTypes, DateTime startDate, DateTime endDate, CenResParamsDTO cenResParams) { string method = "POST"; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("StartDate", startDate.ToString("yyyy-MM-dd")); parameters.Add("EndDate", endDate.ToString("yyyy-MM-dd")); //parameters.Add("StartDate", startDate.ToShortDateString()); //parameters.Add("EndDate", endDate.ToShortDateString()); if (!string.IsNullOrEmpty(cenResParams.Interface)) { // Only SandyLane uses Inventory for now. parameters.Add("InterfaceType", cenResParams.Interface); } var body = new { RoomTypeFilter = roomTypes }; return(SendCenResRequest <List <RoomInfo> >(cenResParams.ServiceUrl, availablityVerbose, method, cenResParams.CendynPropertyId, parameters, body)); }
public List <eUpgradeOptionDTO> GetEventDetail(string hotelCode, string loginComfirmationNum, string roomtype, string ratetype, DateTime?guestArrivaldate, DateTime?guestDeparturedate, int languageId, bool multiLanguageEnabled) { string eventCategory = "RoomUpgrade"; int serviceTemplateID = 3; int languageID = languageId; string spName = "eUpgrade_GetEventDetail"; if (!roomTypeRepo.IsStoredProcedureExists(spName) || !multiLanguageEnabled) { spName = "spGetEventDetail"; languageID = 1; } DateTime?arrivaldate = null; arrivaldate = guestArrivaldate; DateTime?departuredate = null; departuredate = guestDeparturedate; var pList = new Dictionary <string, object>() { { "@eventCategory", eventCategory }, { "@hotelCode", hotelCode }, { "@loginConfirmationNum", loginComfirmationNum }, { "@serviceTemplateID", serviceTemplateID }, { "@languageID", languageID }, { "@ArrivalDate", arrivaldate }, { "@RoomCode", string.IsNullOrWhiteSpace(roomtype) ? string.Empty : roomtype }, { "@RateType", string.IsNullOrWhiteSpace(ratetype) ? string.Empty : ratetype } }; // Store options that comply to business rule but haven't done availability check List <eUpgradeOptionDTO> eUpgradeOptionsRaw = roomTypeRepo.ExecuteStoredProcedure <eUpgradeOptionDTO>(spName, pList); // Store final options List <eUpgradeOptionDTO> eUpgradeOptions = new List <eUpgradeOptionDTO>(); if (eUpgradeOptionsRaw == null || eUpgradeOptionsRaw.Count == 0) { return(eUpgradeOptionsRaw); } var hotel = hotelService.GetHotelByCode(hotelCode); if (string.IsNullOrWhiteSpace(hotel.CendynPropertyId) || string.IsNullOrEmpty(hotel.CenResServiceUrl) || string.IsNullOrEmpty(hotel.CenResServiceInterface)) { // If we do not have a Available API parameters, resume the old logic foreach (var it in eUpgradeOptionsRaw) { it.RoomTypeImages = GetRoomTypeImages(hotelCode, it.EventName); it.OptionPrices = GetOptionPrices(it.ID.Value); } return(eUpgradeOptionsRaw); } else { #region check Roon availability List <string> roomTypes = new List <string>(); //Only chack rooms availability foreach (eUpgradeOptionDTO euo in eUpgradeOptionsRaw) { // If this is an addon, it does not need to check availability var addon = GetRoomTypeCode(hotelCode, euo.EventName).AddOnYN.ToString(); if (addon == "Y") { euo.RoomTypeImages = GetRoomTypeImages(hotelCode, euo.EventName); eUpgradeOptions.Add(euo); } else if (addon == "N") { roomTypes.Add(euo.EventName); } } CenResParamsDTO cenResParams = new CenResParamsDTO() { ServiceUrl = hotel.CenResServiceUrl, Interface = hotel.CenResServiceInterface, CendynPropertyId = hotel.CendynPropertyId, }; //new logic --2 ways List <RoomInfo> roomInfo = cenResService.GetRoomInfos(roomTypes.ToArray(), (DateTime)arrivaldate, (DateTime)departuredate, cenResParams); if (null != roomInfo && roomInfo.Count > 0) { //check Threshold foreach (var option in eUpgradeOptionsRaw) { List <bool> okInDateRange = new List <bool>(); for (DateTime day = (DateTime)arrivaldate; day < (DateTime)departuredate; day = day.AddDays(1)) { bool oneDayOK = false; foreach (var room in roomInfo) { if (option.EventName == room.RoomType && ((option.Threshold.HasValue && option.Threshold < room.AvailableRooms) || option.Threshold.HasValue == false && room.AvailableRooms >= 1) && day == room.Date) { oneDayOK = true; } } okInDateRange.Add(oneDayOK); } if (okInDateRange.Contains(false) == false) { option.RoomTypeImages = GetRoomTypeImages(hotelCode, option.EventName); eUpgradeOptions.Add(option); } } } return(eUpgradeOptions); #endregion } }
public string[] GetAvailableRoomTypes(string[] roomTypes, DateTime startDate, DateTime endDate, CenResParamsDTO cenResParams) { string method = "POST"; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("StartDate", startDate.ToShortDateString()); // Guest depart at endDate so last day in hotel is endDate-1 endDate = endDate.AddDays(-1); parameters.Add("EndDate", endDate.ToShortDateString()); if (!string.IsNullOrEmpty(cenResParams.Interface)) { // Only SandyLane uses Inventory for now. parameters.Add("InterfaceType", cenResParams.Interface); } var body = new { RoomTypeFilter = roomTypes }; return(SendCenResRequest <string[]>(cenResParams.ServiceUrl, availabilitySimple, method, cenResParams.CendynPropertyId, parameters, body)); }
public List <RoomInfo> GetRoomEventDetail(string hotelCode, string loginComfirmationNum, string roomtype, string ratetype, DateTime?guestArrivaldate, DateTime?guestDeparturedate) { string eventCategory = "RoomUpgrade"; int serviceTemplateID = 3; int languageID = 1; string spName = "spGetEventDetail"; DateTime?arrivaldate = null; arrivaldate = guestArrivaldate; DateTime?departuredate = null; departuredate = guestDeparturedate; var pList = new Dictionary <string, object>() { { "@eventCategory", eventCategory }, { "@hotelCode", hotelCode }, { "@loginConfirmationNum", loginComfirmationNum }, { "@serviceTemplateID", serviceTemplateID }, { "@languageID", languageID }, { "@ArrivalDate", arrivaldate }, { "@RoomCode", string.IsNullOrWhiteSpace(roomtype) ? string.Empty : roomtype }, { "@RateType", string.IsNullOrWhiteSpace(ratetype) ? string.Empty : ratetype } }; // Store options that comply to business rule but haven't done availability check List <eUpgradeOptionDTO> eUpgradeOptionsRaw = roomTypeRepo.ExecuteStoredProcedure <eUpgradeOptionDTO>(spName, pList); // Store final options List <eUpgradeOptionDTO> eUpgradeOptions = new List <eUpgradeOptionDTO>(); //if (eUpgradeOptionsRaw == null || eUpgradeOptionsRaw.Count == 0) // return eUpgradeOptionsRaw; var hotel = hotelService.GetHotelByCode(hotelCode); // If we do not have a Availability API to call, resume the old logic //if (string.IsNullOrEmpty(hotel.CenResServiceUrl)) // return eUpgradeOptionsRaw; // Store roomtypes that need to check availability List <string> roomTypes = new List <string>(); foreach (eUpgradeOptionDTO euo in eUpgradeOptionsRaw) { // If this is an addon, it does not need to check availability if (GetRoomTypeCode(hotelCode, euo.EventName).AddOnYN == "Y") { eUpgradeOptions.Add(euo); } else { roomTypes.Add(euo.EventName); } } CenResParamsDTO cenResParams = new CenResParamsDTO() { ServiceUrl = hotel.CenResServiceUrl, Interface = hotel.CenResServiceInterface, CendynPropertyId = hotel.CendynPropertyId, }; string cendynPropertyId = hotel.CendynPropertyId; //cenResService = new CenResService(); //string[] availableRooms = cenResService.GetAvailableRoomTypes(roomTypes.ToArray(), (DateTime)arrivaldate, (DateTime)departuredate, cenResParams); List <RoomInfo> GetRoomInfos = cenResService.GetRoomInfos(roomTypes.ToArray(), (DateTime)arrivaldate, (DateTime)departuredate, cenResParams); List <RoomInfo> GetRoomInfo = new List <RoomInfo>(); //Remove RoomInfo following by threshold criteria foreach (var room in GetRoomInfos) { List <bool> okInDateRange = new List <bool>(); bool oneRTCode = false; foreach (var option in eUpgradeOptionsRaw) { if (option.EventName == room.RoomType && ((option.Threshold.HasValue && option.Threshold < room.AvailableRooms) || option.Threshold.HasValue == false && room.AvailableRooms >= 1)) { oneRTCode = true; } } okInDateRange.Add(oneRTCode); if (okInDateRange.Contains(false) == false) { GetRoomInfo.Add(room); } } return(GetRoomInfo); }