/// <summary> /// Using for Add endDate to current session /// </summary> /// <param name="obj"></param> /// <returns></returns> public async Task Update(BookingAction obj) { if (IsExist(obj)) { _service.BookingActions.Update(obj); } await _service.SaveChangesAsync(); }
/// <summary> /// ___Add Implicit Action___ /// </summary> /// <param name="obj"></param> /// <returns></returns> public async Task Add(BookingAction obj) { if (!IsExist(obj)) { await _service.BookingActions.AddAsync(obj); await _service.SaveChangesAsync(); } }
public async Task GetBookingByAuditoryNumber_ReturnBooking() { //Arrange BookingAction ba = new BookingAction(); //Action var key = keyObjectService.GetByAuditoryName("132").Result; var collection = await bookingActionService.GetAll(x => x.KeyObjectId == key.Id && x.BookingFinish == null); //Assert Assert.IsTrue(collection.Count() > 0); }
/// <summary> /// ___Add object with dateFinish for recording interaction with key in timeline /// </summary> /// <param name="bookingAction"></param> /// <returns></returns> public async Task EndSession(BookingAction bookingAction) { bookingAction.BookingFinish = DateTime.Now; await Task.Run(async() => await Update(bookingAction)); bookingAction.KeyObject.IsBooked = false; bookingAction.KeyObject.User = null; bookingAction.KeyObject.UserId = null; await Task.Run(() => _service.KeyObjects.Update(bookingAction.KeyObject)); await _service.SaveChangesAsync(); }
/// <summary> /// ___Add object with dateStart___ /// </summary> /// <param name="bookingAction"></param> /// <returns></returns> public async Task StartSession(User user, KeyObject keyObject) { try { keyObject.IsBooked = true; keyObject.User = user; keyObject.UserId = user.Id; var res = new BookingAction().AddStartSessionBookingAction(user, keyObject, Guid.NewGuid()); await Add(res); _service.KeyObjects.Update(keyObject); await _service.SaveChangesAsync(); } catch (Exception e) { GC.Collect(); throw; } }
public void InitBookHotelRQ(ref WBSAPIRouterData objWBSAPIRouterData, BookingAction enumBookingAction) { WBSAPIRouterGateway gwWBS = new WBSAPIRouterGateway(objEventLog, objExceptionEventLog, bIsProduction); HotelAvailabilityRS objHotelAvailabilityRS = (HotelAvailabilityRS)Session["HotelAvailabilityRS"]; StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection]; RoomRateSelection[] objRoomRateSelections = (RoomRateSelection[])Session["RoomRateSelections"]; AddOnPackageSelection[] objAddOnPackageSelections = (AddOnPackageSelection[])Session["AddOnPackageSelections"]; GuestDetailsEntryInfo objGuestDetailsEntryInfo = (GuestDetailsEntryInfo)Session["GuestDetailsEntryInfo"]; CancelDetailsEntryInfo objCancelDetailsEntryInfo = (CancelDetailsEntryInfo)Session["CancelDetailsEntryInfo"]; PaymentGatewayInfo[] objPaymentGatewayInfos = (PaymentGatewayInfo[])Session[Constants.Sessions.PaymentGatewayInfos]; PaymentGatewayInfo objPaymentGatewayInfo = (PaymentGatewayInfo)Session[Constants.Sessions.PaymentGatewayInfo]; HotelBookingPaymentAllocation[] objHotelBookingPaymentAllocations = (HotelBookingPaymentAllocation[])Session[Constants.Sessions.HotelBookingPaymentAllocations]; HotelPaymentRQ objHotelPaymentRQ = (HotelPaymentRQ)Session["HotelPaymentRQ"]; HotelPaymentRS objHotelPaymentRS = (HotelPaymentRS)Session["HotelPaymentRS"]; bool bIsOnlinePayment = WBSPGHelper.IsOnlinePayment(objPaymentGatewayInfos, objHotelBookingPaymentAllocations, objGuestDetailsEntryInfo.PaymentCardType); Profile[] objProfiles = (Profile[])Session["LoginProfiles"]; bool bIsLoggedIn = (bool)Session["IsLoggedIn"]; Profile objCompanyProfile = ProfileHelper.GetProfile(objProfiles, ProfileType.Corporation); Profile objAgencyProfile = ProfileHelper.GetProfile(objProfiles, ProfileType.TravelAgent); HotelBookingRQ objHotelBookingRQ = new HotelBookingRQ(); objHotelBookingRQ.RequestHeader = this.GetRequestHeader(); objHotelBookingRQ.BookingAction = enumBookingAction; List<HotelBookingRequestSegment> lSegments = new List<HotelBookingRequestSegment>(); if (enumBookingAction == BookingAction.Sell || enumBookingAction == BookingAction.TestSell || enumBookingAction == BookingAction.Modify) { for (int ri = 0; ri < objStayCriteriaSelection.RoomOccupantSelections.Length; ri++) { HotelBookingRequestSegment objSegment = new HotelBookingRequestSegment(); lSegments.Add(objSegment); string strRoomRefID = objStayCriteriaSelection.RoomOccupantSelections[ri].RoomRefID; HotelRoomAvailInfo objHotelRoomAvailInfo = this.GetHotelRoomAvailInfo(objHotelAvailabilityRS.HotelRoomAvailInfos, strRoomRefID); RoomRateSelection objRoomRateSelection = this.GetRoomRateSelection(objRoomRateSelections, strRoomRefID); HotelAvailRatePlan objHotelAvailRatePlan = this.GetRatePlanInfo(objHotelRoomAvailInfo.RatePlans, objRoomRateSelection.RatePlanCode); AddOnPackageSelection[] objRoomAddOnPackageSelections = this.GetAddOnPackageSelections(objAddOnPackageSelections, strRoomRefID); objSegment.SegmentRefID = strRoomRefID; objSegment.HotelCode = objStayCriteriaSelection.HotelCode; objSegment.ChainCode = ConfigurationManager.AppSettings["HotelChainCode"]; objSegment.ConfirmationNumber = ""; objSegment.ArrivalDate = objStayCriteriaSelection.ArrivalDate.Date; objSegment.DepartureDate = objStayCriteriaSelection.DepartureDate.Date; objSegment.RoomTypeCode = objRoomRateSelection.RoomTypeCode; objSegment.RatePlanCode = objRoomRateSelection.RatePlanCode; objSegment.PromoCode = objStayCriteriaSelection.PromotionCode; objSegment.NumRooms = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberRooms; objSegment.NumAdults = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberAdults; objSegment.NumChildren = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberChildren; // Enhancement: special requests section needs to be "by room" in guest details objSegment.NumCribs = objGuestDetailsEntryInfo.NumberCribs; objSegment.NumRollawaysAdult = objGuestDetailsEntryInfo.NumberRollawaysAdult; objSegment.NumRollawaysChild = objGuestDetailsEntryInfo.NumberRollawaysChild; objSegment.SpecialInstructions = objGuestDetailsEntryInfo.SpecialInstructions; objSegment.IsBaseOccupancyPricing = false; objSegment.NumBaseOccupants = 0; // Enhancement: arrival time needs to be "by room" in guest details objSegment.FlightNumber = objGuestDetailsEntryInfo.FlightNumber; if (objGuestDetailsEntryInfo.ArrivalTime != null && objGuestDetailsEntryInfo.ArrivalTime != "") { DateTime dtArrivalTime; if (DateTime.TryParse(objGuestDetailsEntryInfo.ArrivalTime, out dtArrivalTime)) { objSegment.ArrivalTime = dtArrivalTime; objSegment.ArrivalTimeSpecified = true; } else { objSegment.ArrivalTime = DateTime.Today.Date; objSegment.ArrivalTimeSpecified = false; } } else { objSegment.ArrivalTime = DateTime.Today.Date; objSegment.ArrivalTimeSpecified = false; } List<Profile> lProfiles = new List<Profile>(); Profile objGuest = new Profile(); lProfiles.Add(objGuest); objGuest.Type = ProfileType.Traveler; objGuest.PersonNamePrefix = objGuestDetailsEntryInfo.NamePrefix; objGuest.PersonFirstName = objGuestDetailsEntryInfo.FirstName; objGuest.PersonLastName = objGuestDetailsEntryInfo.LastName; objGuest.CompanyName = ""; objGuest.Address1 = objGuestDetailsEntryInfo.Address1; objGuest.Address2 = objGuestDetailsEntryInfo.Address2; objGuest.City = objGuestDetailsEntryInfo.City; objGuest.StateRegion = objGuestDetailsEntryInfo.StateRegion; objGuest.PostalCode = objGuestDetailsEntryInfo.PostalCode; objGuest.Country = objGuestDetailsEntryInfo.Country; objGuest.Phone = objGuestDetailsEntryInfo.Phone; objGuest.Fax = ""; objGuest.Email = objGuestDetailsEntryInfo.Email; objGuest.SubscribeToNewsletter = objGuestDetailsEntryInfo.SubscribeToNewsletter; objGuest.TravelPurpose = objGuestDetailsEntryInfo.TravelPurpose; List<ProfileIdentifier> lGuestProfileIdentifiers = new List<ProfileIdentifier>(); if (objGuestDetailsEntryInfo.HotelProgramCode != null && objGuestDetailsEntryInfo.HotelProgramCode != "") { ProfileIdentifier objProfileIdentifier = new ProfileIdentifier(); lGuestProfileIdentifiers.Add(objProfileIdentifier); objProfileIdentifier.Type = ProfileIdentifierType.HotelLoyaltyProgram; objProfileIdentifier.ProgramCode = objGuestDetailsEntryInfo.HotelProgramCode; objProfileIdentifier.Identifier = objGuestDetailsEntryInfo.HotelProgramIdentifier; } if (objGuestDetailsEntryInfo.AirlineProgramCode != null && objGuestDetailsEntryInfo.AirlineProgramCode != "") { ProfileIdentifier objProfileIdentifier = new ProfileIdentifier(); lGuestProfileIdentifiers.Add(objProfileIdentifier); objProfileIdentifier.Type = ProfileIdentifierType.AirlineLoyaltyProgram; objProfileIdentifier.ProgramCode = objGuestDetailsEntryInfo.AirlineProgramCode; objProfileIdentifier.Identifier = objGuestDetailsEntryInfo.AirlineProgramIdentifier; } objGuest.ProfileIdentifiers = lGuestProfileIdentifiers.ToArray(); if (objCompanyProfile != null) { lProfiles.Add(objCompanyProfile); } else if (objGuestDetailsEntryInfo.CompanyName != null && objGuestDetailsEntryInfo.CompanyName != "") { Profile objCompany = new Profile(); lProfiles.Add(objCompany); objCompany.Type = ProfileType.Corporation; objCompany.PersonNamePrefix = ""; objCompany.PersonFirstName = ""; objCompany.PersonLastName = ""; objCompany.CompanyName = objGuestDetailsEntryInfo.CompanyName; objCompany.Address1 = ""; objCompany.Address2 = ""; objCompany.City = ""; objCompany.StateRegion = ""; objCompany.PostalCode = ""; objCompany.Country = ""; objCompany.Phone = ""; objCompany.Fax = ""; objCompany.Email = ""; objCompany.SubscribeToNewsletter = false; objCompany.TravelPurpose = TravelPurpose.NotIdentified; objCompany.ProfileIdentifiers = new ProfileIdentifier[0]; } if (objAgencyProfile != null) { lProfiles.Add(objAgencyProfile); } else if (objGuestDetailsEntryInfo.TravelAgencyIATA != null && objGuestDetailsEntryInfo.TravelAgencyIATA != "") { Profile objAgency = new Profile(); lProfiles.Add(objAgency); objAgency.Type = ProfileType.TravelAgent; objAgency.PersonNamePrefix = ""; objAgency.PersonFirstName = ""; objAgency.PersonLastName = ""; objAgency.CompanyName = ""; objAgency.Address1 = ""; objAgency.Address2 = ""; objAgency.City = ""; objAgency.StateRegion = ""; objAgency.PostalCode = ""; objAgency.Country = ""; objAgency.Phone = ""; objAgency.Fax = ""; objAgency.Email = ""; objAgency.SubscribeToNewsletter = false; objAgency.TravelPurpose = TravelPurpose.NotIdentified; ProfileIdentifier objAgencyIATA = new ProfileIdentifier(); objAgencyIATA.Type = ProfileIdentifierType.IATA; objAgencyIATA.Identifier = objGuestDetailsEntryInfo.TravelAgencyIATA; objAgencyIATA.ProgramCode = ""; objAgency.ProfileIdentifiers = new ProfileIdentifier[1]; objAgency.ProfileIdentifiers[0] = objAgencyIATA; } objSegment.Profiles = lProfiles.ToArray(); objSegment.PackageQuantities = new HotelBookingPackageQuantity[objRoomAddOnPackageSelections.Length]; for (int i = 0; i < objRoomAddOnPackageSelections.Length; i++) { HotelBookingPackageQuantity objHotelBookingPackageQuantity = new HotelBookingPackageQuantity(); objSegment.PackageQuantities[i] = objHotelBookingPackageQuantity; objHotelBookingPackageQuantity.Code = objRoomAddOnPackageSelections[i].PackageCode; objHotelBookingPackageQuantity.Quantity = objRoomAddOnPackageSelections[i].Quantity; } objSegment.GuaranteeType = objHotelAvailRatePlan.GuaranteeType; objSegment.PaymentCard = null; objSegment.DepositPaymentAmount = 0; objSegment.PaymentAuthCode = ""; objSegment.PaymentTransRefID = ""; if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.CCDCVoucher && objGuestDetailsEntryInfo.ProfileGuaranteeRequested) { objSegment.GuaranteeType = GuaranteeType.Profile; } else if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.CCDCVoucher) { HotelBookingPaymentCard objPaymentCard = new HotelBookingPaymentCard(); objSegment.PaymentCard = objPaymentCard; objPaymentCard.PaymentCardType = objGuestDetailsEntryInfo.PaymentCardType; objPaymentCard.PaymentCardNumber = objGuestDetailsEntryInfo.PaymentCardNumber; objPaymentCard.PaymentCardHolder = objGuestDetailsEntryInfo.PaymentCardHolder; objPaymentCard.PaymentCardEffectiveDate = objGuestDetailsEntryInfo.PaymentCardEffectiveDate; objPaymentCard.PaymentCardExpireDate = objGuestDetailsEntryInfo.PaymentCardExpireDate; objPaymentCard.PaymentCardIssueNumber = objGuestDetailsEntryInfo.PaymentCardIssueNumber; objPaymentCard.PaymentCardSecurityCode = objGuestDetailsEntryInfo.PaymentCardSecurityCode; objSegment.CurrencyCode = objHotelAvailRatePlan.DepositRequiredCurrencyCode; } else if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.Deposit || objHotelAvailRatePlan.GuaranteeType == GuaranteeType.PrePay) { HotelBookingPaymentCard objPaymentCard = new HotelBookingPaymentCard(); objSegment.PaymentCard = objPaymentCard; objPaymentCard.PaymentCardType = objGuestDetailsEntryInfo.PaymentCardType; objPaymentCard.PaymentCardNumber = objGuestDetailsEntryInfo.PaymentCardNumber; objPaymentCard.PaymentCardHolder = objGuestDetailsEntryInfo.PaymentCardHolder; objPaymentCard.PaymentCardEffectiveDate = objGuestDetailsEntryInfo.PaymentCardEffectiveDate; objPaymentCard.PaymentCardExpireDate = objGuestDetailsEntryInfo.PaymentCardExpireDate; objPaymentCard.PaymentCardIssueNumber = objGuestDetailsEntryInfo.PaymentCardIssueNumber; objPaymentCard.PaymentCardSecurityCode = objGuestDetailsEntryInfo.PaymentCardSecurityCode; objSegment.CurrencyCode = objHotelAvailRatePlan.DepositRequiredCurrencyCode; decimal decDepositPaymentAmount = WBSPGHelper.GetBookingSegmentPayment(objHotelBookingPaymentAllocations, strRoomRefID); if (bIsOnlinePayment && decDepositPaymentAmount != 0) { objSegment.PaymentCard = objHotelPaymentRS.PaymentCard; objSegment.DepositPaymentAmount = decDepositPaymentAmount; objSegment.PaymentAuthCode = objHotelPaymentRS.PaymentAuthCode; objSegment.PaymentTransRefID = objHotelPaymentRS.PaymentTransRefID; objSegment.PaymentCard.PaymentCardSecurityCode = ""; // remove security code (no longer needed) } } } } if (enumBookingAction == BookingAction.Cancel) { for (int ci = 0; ci < objCancelDetailsEntryInfo.SelectedConfirmationNumbersToCancel.Length; ci++) { HotelBookingRequestSegment objSegment = new HotelBookingRequestSegment(); lSegments.Add(objSegment); objSegment.SegmentRefID = ((int)(ci + 1)).ToString(); objSegment.ConfirmationNumber = objCancelDetailsEntryInfo.SelectedConfirmationNumbersToCancel[ci]; } } objHotelBookingRQ.Segments = lSegments.ToArray(); gwWBS.InitHotelBookingRQ(ref objWBSAPIRouterData, objHotelBookingRQ); return; }
public BookingActionPM(int resourceId, int bookingId, BookingAction type, string message, int createBy, DateTime createAt) : base(resourceId, bookingId, type, message, createBy, createAt) { }
/// <summary> /// Send a booking notification (create, edit or delete event) as email to in config file defined receivers /// </summary> /// <param name="bookingAction">For which action the notification will be send. (create, edit or delete event)</param> /// <returns></returns> /// <remarks></remarks> public static void SendBookingNotification(BookingAction bookingAction, BookingEventModel model) { //get receiver and sender from the settings file var receiver = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiver").ToString().Split(',').ToList(); var receiverCC = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverCC").ToString().Split(',').ToList(); var receiverBCC = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverBCC").ToString().Split(',').ToList(); var sender = Modules.RBM.UI.Helper.Settings.get("BookingMailSender").ToString(); var subject = Modules.RBM.UI.Helper.Settings.get("BookingMailSubject").ToString() + ": " + bookingAction; string message = ""; message += "<p>The following booking has been " + bookingAction + "</p>"; message += "<b>Booking name: </b>" + model.Name + "</br>"; if (!String.IsNullOrEmpty(model.Description)) { message += "<b>Booking description: </b> " + model.Description + "</br>"; } message += "<p><b>Booked Resources:</b></p>"; using (var userManager = new UserManager()) using (var partyManager = new PartyManager()) { foreach (ScheduleEventModel schedule in model.Schedules) { message += "<b>Resource: </b>" + schedule.ResourceName + "</br>"; message += "<b>Start date: </b>" + schedule.ScheduleDurationModel.StartDate.ToString("dd.MM.yyyy") + "</br>"; message += "<b>End date: </b>" + schedule.ScheduleDurationModel.EndDate.ToString("dd.MM.yyyy") + "</br>"; message += "<b>Reserved by: </b>" + schedule.ByPerson + "</br>"; message += "<b>Contact person: </b>" + schedule.ContactName + " ( #" + schedule.Contact.MobileNumber + ")</br>"; message += "<b>Reserved for: </b>"; foreach (PersonInSchedule person in schedule.ForPersons) { if (schedule.ForPersons.IndexOf(person) == schedule.ForPersons.Count - 1) { message += person.UserFullName; } else { message += person.UserFullName + ", "; } var user = userManager.FindByIdAsync(person.UserId).Result; if (user != null) { receiver.Add(user.Email); } } message += "</br></br>"; } } receiverBCC.Add(ConfigurationManager.AppSettings["SystemEmail"].ToString()); // Allways send BCC to SystemEmail var emailService = new EmailService(); emailService.Send( subject, message, receiver.Distinct().ToList(), receiverCC, receiverBCC ); }
public Task <bool> Delete(BookingAction obj) { throw new NotImplementedException(); }
private bool IsExist(BookingAction bookingAction) { return(_service.BookingActions.Any(x => x.Id == bookingAction.Id)); }
public BookingsController(BookingAction bookingAction) { _bookingAction = bookingAction; }
/// <summary> /// Generates the notifications for bookings. /// </summary> /// <param name="userID">The user identifier.</param> /// <param name="itemBriefId">The item brief identifier.</param> /// <param name="itemId">The item identifier.</param> /// <param name="projectId">The project identifier.</param> /// <param name="action">The action.</param> public void GenerateNotificationsForBookings(int userID, int itemBriefId, int itemId, int projectId, BookingAction action) { PersonalBL personalBL = new PersonalBL(DataContext); User user = personalBL.GetUser(userID); string userName = string.Concat(user.FirstName + " " + user.LastName).Trim(); InventoryBL inventoryBL = new InventoryBL(DataContext); Data.Item item = inventoryBL.GetItem(itemId); ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext); Data.ItemType itemType = itemBriefBL.GetItemBriefType(itemBriefId).ItemType; if (itemType != null && item != null) { StageBitz.Data.Notification nf = new StageBitz.Data.Notification(); nf.CreatedByUserId = nf.LastUpdatedByUserId = userID; nf.CreatedDate = nf.LastUpdatedDate = Utils.Now; nf.RelatedId = itemBriefId; nf.ProjectId = projectId; nf.ModuleTypeCodeId = Utils.GetCodeIdByCodeValue("ModuleType", "ITEMBRIEFBOOKING"); string message = string.Empty; switch (action) { case BookingAction.Pin: message = "{0} pinned {1} from the Company Inventory to this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "PIN"); break; case BookingAction.Keep: message = "{0} confirmed {1} from the Company Inventory to use for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "KEEP"); break; case BookingAction.Remove: message = "{0} returned {1} to the Company Inventory and removed it as an option for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "REMOVE"); break; case BookingAction.RemoveWithSnapshot: message = "{0} released {1} to the Company Inventory and kept a record for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "REMOVE"); break; } nf.Message = string.Format(message, userName, item.Name, itemType.Name); this.AddNotification(nf); } }