예제 #1
0
        protected override Task <ICommandResult> Handle(SaveEventTicketAttributeCommand command)
        {
            var EventTickeAttribute = new EventTicketAttribute();
            SaveEventTicketAttributeResult saveEventTicketAttributelResult = new SaveEventTicketAttributeResult();
            var checkForEventTicketAttribute = _eventTicketAttributeRepository.Get(command.Id);

            if (checkForEventTicketAttribute != null)
            {
                EventTickeAttribute = new EventTicketAttribute
                {
                    Id = checkForEventTicketAttribute.Id,
                    EventTicketDetailId       = command.EventTicketDetailId,
                    SalesStartDateTime        = command.SalesStartDateTime,
                    SalesEndDatetime          = command.SalesEndDatetime,
                    TicketTypeId              = (TicketType)command.TicketTypeId,
                    ChannelId                 = (Channels)command.ChannelId,
                    CurrencyId                = command.CurrencyId,
                    AvailableTicketForSale    = command.AvailableTicketForSale,
                    RemainingTicketForSale    = command.AvailableTicketForSale,
                    TicketCategoryDescription = command.TicketCategoryDescription,
                    ViewFromStand             = command.ViewFromStand,
                    IsSeatSelection           = false,
                    Price = command.price,
                    IsInternationalCardAllowed = false,
                    IsEMIApplicable            = false,
                    LocalPrice         = command.price,
                    SeasonPackage      = false,
                    SeasonPackagePrice = 0,
                    LocalCurrencyId    = command.CurrencyId,
                    IsEnabled          = command.IsEnabled,
                    CreatedUtc         = DateTime.UtcNow,
                    CreatedBy          = command.ModifiedBy
                };
            }
            else
            {
                EventTickeAttribute = new EventTicketAttribute
                {
                    Id = command.Id,
                    EventTicketDetailId       = command.EventTicketDetailId,
                    SalesStartDateTime        = command.SalesStartDateTime,
                    SalesEndDatetime          = command.SalesEndDatetime,
                    TicketTypeId              = (TicketType)command.TicketTypeId,
                    ChannelId                 = (Channels)command.ChannelId,
                    CurrencyId                = command.CurrencyId,
                    AvailableTicketForSale    = command.AvailableTicketForSale,
                    RemainingTicketForSale    = command.AvailableTicketForSale,
                    TicketCategoryDescription = command.TicketCategoryDescription,
                    ViewFromStand             = command.ViewFromStand,
                    IsSeatSelection           = false,
                    Price = command.price,
                    IsInternationalCardAllowed = false,
                    IsEMIApplicable            = false,
                    LocalPrice         = command.price,
                    SeasonPackage      = false,
                    SeasonPackagePrice = 0,
                    LocalCurrencyId    = command.CurrencyId,
                    IsEnabled          = command.IsEnabled,
                    CreatedUtc         = DateTime.UtcNow,
                    CreatedBy          = command.ModifiedBy
                };
            }

            FIL.Contracts.DataModels.EventTicketAttribute result = _eventTicketAttributeRepository.Save(EventTickeAttribute);
            saveEventTicketAttributelResult.Id = result.Id;
            return(Task.FromResult <ICommandResult>(saveEventTicketAttributelResult));
        }
예제 #2
0
        public async Task <ASIBookingResponse> saveASIData(ASIBooking aSIBooking)
        {
            var            transactionData    = _transactionRepository.Get(aSIBooking.TransactionId);
            var            transactionDetails = _transactionDetailRepository.GetByTransactionId(aSIBooking.TransactionId);
            List <Visitor> visitors           = new List <Visitor>();
            List <ASIHash> aSIHashes          = new List <ASIHash>();
            RootObject     rootObject         = new RootObject();

            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var clientETAData = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId && (TicketType)currentTransactionDetail.TicketTypeId == s.TicketType).FirstOrDefault();
                if (clientETAData != null)
                {
                    foreach (FIL.Contracts.Commands.Transaction.GuestUserDetail currentGuestDetail in clientETAData.GuestDetails)
                    {
                        _saveGuestUserProvider.SaveGuestUsers(currentGuestDetail, currentTransactionDetail);
                    }

                    _aSITransactionDetailTimeSlotIdMappingRepository.Save(new FIL.Contracts.DataModels.ASI.ASITransactionDetailTimeSlotIdMapping
                    {
                        EventTimeSlotMappingId = (long)clientETAData.VisitTimeId,
                        TransactionDetailId    = currentTransactionDetail.Id,
                        IsEnabled  = true,
                        CreatedUtc = DateTime.UtcNow,
                        UpdatedUtc = DateTime.UtcNow
                    });

                    _transactionDeliveryDetailRepository.Save(new TransactionDeliveryDetail
                    {
                        TransactionDetailId = currentTransactionDetail.Id,
                        DeliveryTypeId      = DeliveryTypes.PrintAtHome,
                        PickupBy            = 1,
                        SecondaryName       = "Zoonga",
                        SecondaryContact    = "Zoonga",
                        SecondaryEmail      = transactionData.EmailId,
                        PickUpAddress       = "Zoonga"
                    });
                }
            }
            // This is separate loop for API request payload..... I don't think we need to manage data from above loop... Better to keep it separate
            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var guestData          = _guestDetailRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                var asiTicketAttribute = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault();
                if (guestData.Any())
                {
                    var currentETA        = _eventTicketAttributeRepository.Get(currentTransactionDetail.EventTicketAttributeId);
                    var currentETD        = _eventTicketDetailRepository.Get(currentETA.EventTicketDetailId);
                    var currentTc         = _ticketCategoryRepository.Get((int)currentETD.TicketCategoryId);
                    var currentED         = _eventDetailRepository.Get(currentETD.EventDetailId);
                    var currentE          = _eventRepository.Get(currentED.EventId);
                    var asiETableMapping  = _aSIMonumentEventTableMappingRepository.GetByEventId(currentE.Id);
                    var asiMonument       = _aSIMonumentRepository.Get(asiETableMapping.ASIMonumentId);
                    var asiMonumentDetail = _aSIMonumentDetailRepository.GetByNameAndMonumentId(currentED.Name, asiMonument.Id);
                    var asiTimeSlot       = _aSITransactionDetailTimeSlotIdMappingRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                    var eventTimeSlot     = _eventTimeSlotMappingRepository.Get(asiTimeSlot.EventTimeSlotMappingId);
                    //api.key |[monument.code | optional | date | age | country | amount] |[monument.code | optional | date | age | country | amount] | api.salt
                    foreach (FIL.Contracts.DataModels.GuestDetail currentGuestDetail in guestData)
                    {
                        Visitor     visitor     = new Visitor();
                        ASIHash     aSIHash     = new ASIHash();
                        Identity    indentity   = new Identity();
                        Monument    monument    = new Monument();
                        Nationality nationality = new Nationality();
                        Timeslot    timeslot    = new Timeslot();
                        visitor.Identity          = indentity;
                        visitor.Monument          = monument;
                        visitor.Monument.Timeslot = timeslot;
                        visitor.Nationality       = nationality;
                        var custerDocType = _customerDocumentTypeRepository.Get(currentGuestDetail.CustomerDocumentTypeId);
                        visitor.Age                  = Convert.ToInt32(currentGuestDetail.Age);
                        visitor.VisitorId            = currentGuestDetail.Id.ToString();
                        visitor.Amount               = currentTransactionDetail.PricePerTicket;
                        visitor.Gender               = currentGuestDetail.GenderId.ToString();
                        visitor.Name                 = currentGuestDetail.FirstName + " " + currentGuestDetail.LastName;
                        visitor.Date                 = ((System.DateTime)currentTransactionDetail.VisitDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                        visitor.Identity.Type        = custerDocType.DocumentType;
                        visitor.Identity.No          = currentGuestDetail.DocumentNumber;
                        visitor.Monument.Code        = "TAJ";
                        visitor.Monument.Optional    = asiMonumentDetail.IsOptional;
                        visitor.Monument.Main        = true;
                        visitor.Monument.Timeslot.Id = eventTimeSlot.TimeSlotId;
                        visitor.Nationality.Group    = currentTc.Name;
                        visitor.Nationality.Country  = asiTicketAttribute == null ? "India" : asiTicketAttribute.ASIUserSelectedCountry;
                        visitors.Add(visitor);

                        aSIHash.Code           = asiMonument.Code;
                        aSIHash.IsOptional     = asiMonumentDetail.IsOptional;
                        aSIHash.Date           = (System.DateTime)currentTransactionDetail.VisitDate;
                        aSIHash.Nationality    = currentTc.Name;
                        aSIHash.Age            = Convert.ToInt32(currentGuestDetail.Age);
                        aSIHash.Amount         = currentTransactionDetail.PricePerTicket;
                        aSIHash.IdentityType   = "Passport";
                        aSIHash.IdentityNumber = "SADFG";
                        aSIHash.VisitorId      = currentGuestDetail.Id.ToString();
                        aSIHashes.Add(aSIHash);
                    }
                }
            }

            var ticketHash = "";

            foreach (FIL.Contracts.Models.ASI.ASIHash currentHash in aSIHashes)
            {
                TimeZoneInfo INDIAN_ZONE;
                try
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                }
                catch (Exception e)
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("Asia/Kolkata");
                }
                DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(currentHash.Date, INDIAN_ZONE);
                var      time       = indianTime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                ticketHash = ticketHash + "[" + currentHash.Code + "|" + (!currentHash.IsOptional).ToString().ToLower() + "|" + currentHash.IsOptional.ToString().ToLower() + "|" + indianTime.ToString("yyyy-MM-dd") + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "]" + "|";
                //ticketHash = ticketHash + "[" + "TAJ" + "|" + time + "|" + currentHash.IdentityType + "|" + currentHash.IdentityNumber + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "|" + currentHash.VisitorId + "]" + "|";
            }
            var bookingHashRequestData = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey) + "|" + ticketHash + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APISalt);
            var bookingHash            = GenerateSHA512Hash(bookingHashRequestData);

            rootObject.TransactionId = aSIBooking.TransactionId.ToString();
            rootObject.Hash          = bookingHash.ToLower();
            rootObject.Visitors      = visitors;
            rootObject.Email         = transactionData.EmailId == "*****@*****.**" ? transactionData.PhoneNumber : transactionData.EmailId;
            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(string.Empty, aSIBooking.UserId);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = aSIBooking.UserId,
                    AltId       = new Guid(),
                    NameOnCard  = string.Empty,
                    CardNumber  = string.Empty,
                    ExpiryMonth = 12,
                    ExpiryYear  = 2020,
                    CardTypeId  = CardType.None
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            _transactionPaymentDetailRepository.Save(new TransactionPaymentDetail // Create transaction payment request before calling booking POST API request...
            {
                TransactionId    = aSIBooking.TransactionId,
                PaymentOptionId  = PaymentOptions.None,
                PaymentGatewayId = PaymentGateway.Payu,
                UserCardDetailId = userCardDetail.Id,
                RequestType      = "Charge Posting",
                Amount           = transactionData.NetTicketAmount.ToString(),
                PayConfNumber    = "",
                PaymentDetail    = "{\"Request\":" + Newtonsoft.Json.JsonConvert.SerializeObject(rootObject) + "{\"hashparameter\":" + bookingHashRequestData + "}}",
            });
            var baseAddress = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.IntegrationRoot).ToString() + "" + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey).ToString();

            return(new ASIBookingResponse
            {
                RootObject = rootObject,
                ReturnUrl = baseAddress
            });
        }
예제 #3
0
        public List <PAHDetail> GetPAHDetails(long transactionId)
        {
            var transactionDetail = _transactionDetailRepository.GetByTransactionId(transactionId);

            try
            {
                var feelBarcodeMapping = _feelBarcodeMappingRepository.GetByTransactionDetailIds(transactionDetail.Select(s => s.Id)).ToList();
                List <PAHDetail>           listPAHDetails          = new List <PAHDetail>();
                List <CategoryWiseTickets> categoryWiseTicketsList = new List <CategoryWiseTickets>();
                long[] transactionDetailIds = new long[feelBarcodeMapping.Count];
                if (feelBarcodeMapping.Count() > 0)
                {
                    int i = 0, totalTickets = 0; decimal grptotalPrice = 0;
                    foreach (FeelBarcodeMapping currentBarcode in feelBarcodeMapping)
                    {
                        i++;
                        PAHDetail           pAHDetail           = new PAHDetail();
                        CategoryWiseTickets categoryWiseTickets = new CategoryWiseTickets();
                        var currentTransaction = _transactionRepository.Get(transactionId);
                        // check for hoho timeslot
                        var citySightSeeingTransaction = _citySightSeeingTransactionDetailRepository.GetByTransactionId(currentTransaction.Id);
                        if (citySightSeeingTransaction.HasTimeSlot && citySightSeeingTransaction.TimeSlot != null)
                        {
                            var formatTimeSlot = citySightSeeingTransaction.TimeSlot.Split(":");
                            pAHDetail.TimeSlot = formatTimeSlot[0] + ":" + formatTimeSlot[1];
                        }
                        var currentTransactionDetail     = _transactionDetailRepository.Get(currentBarcode.TransactionDetailId);
                        var currentEventTicketAttributes = _eventTicketAttributeRepository.Get((int)currentTransactionDetail.EventTicketAttributeId);
                        var currentEventTicketDetail     = _eventTicketDetailRepository.Get(currentEventTicketAttributes.EventTicketDetailId);
                        var currentTicketCategory        = _ticketCategoryRepository.Get((int)currentEventTicketDetail.TicketCategoryId);
                        var currentEventDetails          = _eventDetailRepository.Get(currentEventTicketDetail.EventDetailId);
                        var curretVenue = _venueRepository.Get(currentEventDetails.VenueId);
                        var currentCity = _cityRepository.Get(curretVenue.CityId);
                        var currentstate = _stateRepository.Get(currentCity.StateId);
                        var currentcountry = _countryRepository.Get(currentstate.CountryId);
                        var currentEvent = _eventRepository.Get(currentEventDetails.EventId);
                        var currentCurrencyType = _currencyTypeRepository.Get(currentEventTicketAttributes.CurrencyId);
                        var flag = true; var ticketCatName = currentTicketCategory.Name;
                        grptotalPrice += currentEventTicketAttributes.Price;
                        totalTickets  += currentTransactionDetail.TotalTickets;
                        categoryWiseTickets.CategoryName = currentTicketCategory.Name;
                        categoryWiseTickets.TotalTickets = currentTransactionDetail.TotalTickets;
                        if (currentBarcode.GroupCodeExist)
                        {
                            flag = false;
                            if (!transactionDetailIds.Contains(currentBarcode.TransactionDetailId))
                            {
                                transactionDetailIds[i - 1] = currentBarcode.TransactionDetailId;
                                categoryWiseTicketsList.Add(categoryWiseTickets);
                            }
                        }
                        if (currentBarcode.GroupCodeExist && feelBarcodeMapping.Count == i)
                        {
                            flag          = true;
                            ticketCatName = "Group";
                        }
                        if (flag)
                        {
                            pAHDetail.EventId             = currentEvent.Id;
                            pAHDetail.EventName           = currentEvent.Name;
                            pAHDetail.EventStartTime      = (DateTime)currentTransactionDetail.VisitDate;
                            pAHDetail.EventsourceId       = (long)(EventSource)Enum.Parse(typeof(EventSource), currentEvent.EventSourceId.ToString());
                            pAHDetail.Price               = currentBarcode.GroupCodeExist ? grptotalPrice : currentEventTicketAttributes.Price;
                            pAHDetail.TicketCategoryName  = ticketCatName;
                            pAHDetail.TotalTickets        = currentBarcode.GroupCodeExist ? totalTickets : currentTransactionDetail.TotalTickets;
                            pAHDetail.EventDetailsName    = currentEventDetails.Name;
                            pAHDetail.VenueId             = curretVenue.Id;
                            pAHDetail.VenueName           = curretVenue.Name;
                            pAHDetail.CityName            = currentCity.Name;
                            pAHDetail.CountryName         = currentcountry.Name;
                            pAHDetail.BarcodeNumber       = currentBarcode.Barcode;
                            pAHDetail.CurrencyName        = currentCurrencyType.Code;
                            pAHDetail.EventDeatilId       = currentEventDetails.Id;
                            pAHDetail.FirstName           = currentTransaction.FirstName;
                            pAHDetail.LastName            = currentTransaction.LastName;
                            pAHDetail.EmailId             = currentTransaction.EmailId;
                            pAHDetail.PhoneNumber         = currentTransaction.PhoneNumber;
                            pAHDetail.TransactionId       = currentTransaction.Id;
                            pAHDetail.CategoryWiseTickets = AutoMapper.Mapper.Map <List <CategoryWiseTickets> >(categoryWiseTicketsList);
                            listPAHDetails.Add(pAHDetail);
                        }
                    }
                    return(listPAHDetails);
                }
                else
                {
                    return(listPAHDetails);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, new Exception(ex.Message));
                return(null);
            }
        }
예제 #4
0
        protected override async Task <ICommandResult> Handle(ZoomValidateUserCommand command)
        {
            ZoomValidateUserCommandResult zoomValidateUserCommandResult = new ZoomValidateUserCommandResult();

            try
            {
                var zoomUserModel = _zoomUserRepository.GetByAltId(command.AltId);
                var getTimeStamp  = GetTimeStamp(zoomUserModel);
                zoomValidateUserCommandResult.timeStamp = getTimeStamp;
                //var checkTimeStamp = CheckValidTimeStamp(zoomUserModel);
                //if (!checkTimeStamp.IsValid)
                //{
                //    zoomValidateUserCommandResult.message = checkTimeStamp.Message;
                //    zoomValidateUserCommandResult.success = false;
                //    return zoomValidateUserCommandResult;
                //}
                if (zoomUserModel == null)
                {
                    if (zoomUserModel == null)
                    {
                        zoomValidateUserCommandResult.message = Constant.Zoom.Message.Invalid;
                    }
                    else
                    {
                        zoomValidateUserCommandResult.message = Constant.Zoom.Message.Active;
                    }
                    zoomValidateUserCommandResult.success = false;
                    return(zoomValidateUserCommandResult);
                }
                else
                {
                    string apikey    = _settings.GetConfigSetting <string>(SettingKeys.Integration.Zoom.API_Key);
                    string apiSecret = _settings.GetConfigSetting <string>(SettingKeys.Integration.Zoom.Secret_key);

                    var zoomMeetingModel = _zoomMeetingRepository.GetByEventId(zoomUserModel.EventId);

                    //Interactivity levels available
                    zoomValidateUserCommandResult.isAudioAvailable = true;
                    zoomValidateUserCommandResult.isVideoAvailable = true;
                    zoomValidateUserCommandResult.isChatAvailable  = true;

                    bool isHost         = false;
                    var  access         = Access.None;
                    var  eventHostModel = new EventHostMapping();
                    if (zoomUserModel.RoleId != 21 && zoomUserModel.RoleId != 26) // If the user is attendee
                    {
                        var userModel = _userRepository.Get(zoomUserModel.UserId);
                        zoomValidateUserCommandResult.email     = userModel.Email;
                        zoomValidateUserCommandResult.userName  = userModel.FirstName + " " + userModel.LastName;
                        zoomValidateUserCommandResult.UserAltId = userModel.AltId;
                        var transactionDetailsModel = _transactionRepository.GetFeelOnlineDetails(zoomUserModel.TransactionId).Where(s => s.TransactionType == Contracts.Enums.TransactionType.LiveOnline).FirstOrDefault();
                        if (transactionDetailsModel == null)
                        {
                            return(zoomValidateUserCommandResult);
                        }
                        //interactivity levels available based on ticket cat.
                        if (transactionDetailsModel.TicketCategoryId == 1360)
                        {
                            access = Access.GA;
                            zoomValidateUserCommandResult.isAudioAvailable = false;
                            zoomValidateUserCommandResult.isVideoAvailable = false;
                            zoomValidateUserCommandResult.isChatAvailable  = false;
                        }
                        if (transactionDetailsModel.TicketCategoryId == 606)
                        {
                            access = Access.VIP;
                            zoomValidateUserCommandResult.isAudioAvailable = false;
                            zoomValidateUserCommandResult.isVideoAvailable = false;
                        }
                        if (transactionDetailsModel.TicketCategoryId == 12080 || transactionDetailsModel.TicketCategoryId == 19352)
                        {
                            zoomValidateUserCommandResult.isVideoAvailable = false;
                        }
                    }
                    else // Host user
                    {
                        eventHostModel = _eventHostMappingRepository.Get(zoomUserModel.EventHostUserId);
                        zoomValidateUserCommandResult.email    = eventHostModel.Email;
                        zoomValidateUserCommandResult.userName = eventHostModel.FirstName + " " + eventHostModel.LastName;
                        isHost = true;
                    }

                    zoomValidateUserCommandResult.meetingNumber = zoomMeetingModel.MeetingNumber.ToString();
                    zoomValidateUserCommandResult.apikey        = apikey;
                    zoomValidateUserCommandResult.secretkey     = apiSecret;
                    zoomValidateUserCommandResult.success       = true;
                    zoomValidateUserCommandResult.roleId        = (zoomUserModel.RoleId == 21 || zoomUserModel.RoleId == 26) ? "1" : "0";

                    if (!zoomUserModel.IsActive && command.IsZoomLandingPage)
                    {
                        zoomUserModel.UniqueId = command.UniqueId;
                        zoomUserModel.IsActive = true;
                        _zoomUserRepository.Save(zoomUserModel);
                    }
                    var eventDetail = _eventDetailRepository.GetAllByEventId(zoomUserModel.EventId).FirstOrDefault();
                    zoomValidateUserCommandResult.eventName = eventDetail.Name;
                    if (!command.IsZoomLandingPage)
                    {
                        zoomValidateUserCommandResult.EventAttribute    = _eventAttributeRepository.GetByEventDetailId(eventDetail.Id);
                        zoomValidateUserCommandResult.EventHostMappings = _eventHostMappingRepository.GetAllByEventId(eventDetail.EventId).OrderBy(s => s.StartDateTime).ToList();
                        foreach (var currentEHM in zoomValidateUserCommandResult.EventHostMappings)
                        {
                            currentEHM.StartDateTime = currentEHM.StartDateTime != null?_localTimeZoneConvertProvider.ConvertToLocal((DateTime)currentEHM.StartDateTime, zoomValidateUserCommandResult.EventAttribute.TimeZone) : currentEHM.StartDateTime;

                            currentEHM.EndDateTime = currentEHM.EndDateTime != null?_localTimeZoneConvertProvider.ConvertToLocal((DateTime)currentEHM.EndDateTime, zoomValidateUserCommandResult.EventAttribute.TimeZone) : currentEHM.EndDateTime;
                        }
                        zoomValidateUserCommandResult.EventDetail     = _eventDetailRepository.Get(eventDetail.Id);
                        zoomValidateUserCommandResult.LiveEventDetail = _liveEventDetailRepository.GetByEventId(eventDetail.EventId);
                        if (isHost && eventHostModel.StartDateTime != null && zoomValidateUserCommandResult.LiveEventDetail != null)
                        {
                            zoomValidateUserCommandResult.LiveEventDetail.EventStartDateTime = eventHostModel.StartDateTime;
                        }
                        zoomValidateUserCommandResult.Event = _eventRepository.Get(eventDetail.EventId);
                        var eventTicketDetails    = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.Id).Where(s => s.IsEnabled).ToList();
                        var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => s.Id)).Where(s => s.IsEnabled).ToList();
                        if (eventTicketDetails.Select(s => s.TicketCategoryId).Contains(19452) || eventTicketDetails.Select(s => s.TicketCategoryId).Contains(12259)) // if donate
                        {
                            zoomValidateUserCommandResult.IsDonate = true;
                        }
                        if ((access == Access.GA || access == Access.VIP) && eventTicketDetails.Select(s => s.TicketCategoryId).Contains(19350) || eventTicketDetails.Select(s => s.TicketCategoryId).Contains(12079)) // if BSP Exists
                        {
                            var price       = getBSPPrice(eventTicketDetails, eventTicketAttributes) - (access == Access.GA ? getGAPrice(eventTicketDetails, eventTicketAttributes) : getVIP(eventTicketDetails, eventTicketAttributes));
                            var transacions = _transactionRepository.GetAllSuccessfulTransactionByReferralId(zoomUserModel.TransactionId.ToString());
                            if (price >= 0 && !transacions.Any())
                            {
                                zoomValidateUserCommandResult.IsUpgradeToBSP = true;
                                zoomValidateUserCommandResult.Price          = price;
                            }
                        }
                        if (zoomUserModel.RoleId != 21 && zoomUserModel.RoleId != 26) // If the user is attendee
                        {
                            var transactionDetail = _transactionDetailRepository.GetByTransactionId(zoomUserModel.TransactionId);
                            var eta = _eventTicketAttributeRepository.Get(transactionDetail.Count() > 1 ? transactionDetail.Where(s => s.TransactionType == Contracts.Enums.TransactionType.LiveOnline).FirstOrDefault().EventTicketAttributeId : transactionDetail.FirstOrDefault().EventTicketAttributeId);
                            zoomValidateUserCommandResult.ImportantInformation = eta.TicketCategoryNotes;
                            /* If Recurring then update Event Start & Interactivity start time */
                            if (eventDetail.EventFrequencyType == Contracts.Enums.EventFrequencyType.Recurring)
                            {
                                UpdateEventSchedule(zoomValidateUserCommandResult, transactionDetail.ToList());
                            }
                        }
                        else
                        {
                            zoomValidateUserCommandResult.ImportantInformation = zoomValidateUserCommandResult.EventHostMappings.Where(s => s.Id == zoomUserModel.EventHostUserId).FirstOrDefault().ImportantInformation;
                        }
                    }
                }
                zoomValidateUserCommandResult.success       = true;
                zoomValidateUserCommandResult.TransactionId = zoomUserModel.TransactionId;
                return(zoomValidateUserCommandResult);
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, new Exception("Failed to validate zoom details " + e.Message, e));
                return(zoomValidateUserCommandResult);
            }
        }
예제 #5
0
        protected override Task <ICommandResult> Handle(ApplyDiscountCommand command)
        {
            var transaction = _transactionRepository.Get(command.TransactionId);

            var     transactionDetails  = _transactionDetailRepository.GetByTransactionId(command.TransactionId);
            var     ipDetail            = _iPDetailRepository.Get((int)transaction.IPDetailId);
            decimal totalDiscountAmount = 0;
            decimal discountAmount      = 0;

            foreach (TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var eventTicketDetailDiscount = _eventTicketDiscountDetailRepository.GetAllByEventTicketAttributeId(currentTransactionDetail.EventTicketAttributeId).ToList();
                if (eventTicketDetailDiscount.Count() > 0 && currentTransactionDetail.TicketTypeId != 4)
                {
                    List <long> discountIds = new List <long>();
                    foreach (var currentEventTicketDetailDiscount in eventTicketDetailDiscount)
                    {
                        discountIds.Add(currentEventTicketDetailDiscount.DiscountId);
                    }
                    var discounts = _discountRepository.GetAllDiscountsByIds(discountIds).Where(w => w.IsEnabled);
                    if (discounts.Count() > 0)
                    {
                        List <long> Ids = new List <long>();
                        foreach (var id in discounts)
                        {
                            Ids.Add(id.Id);
                        }
                        var discountPromoCode = _discountPromoCodeRepository.GetAllDiscountIds(Ids).Where(s => s.PromoCode == command.Promocode).FirstOrDefault();
                        if (discountPromoCode != null)
                        {
                            //Check for limit
                            bool limitFlag = true;
                            if (discountPromoCode.Limit != null && discountPromoCode.Limit != 0)
                            {
                                var promoCodeTransactions       = _transactionRepository.GetSuccessfullTransactionByPromoCode(discountPromoCode.PromoCode).ToList();
                                var promocodeTransactionDetails = _transactionDetailRepository.GetByTransactionIds(promoCodeTransactions.Select(s => s.Id)).Where(w => w.EventTicketAttributeId == currentTransactionDetail.EventTicketAttributeId);

                                if (promocodeTransactionDetails.Count() >= discountPromoCode.Limit)
                                {
                                    limitFlag = false;
                                }
                            }
                            if (limitFlag)
                            {
                                if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat)
                                {
                                    discountAmount = (decimal)(currentTransactionDetail.TotalTickets * discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValue);
                                    if (discountAmount == (currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets))
                                    {
                                        currentTransactionDetail.ConvenienceCharges = 0;
                                        currentTransactionDetail.ServiceCharge      = 0;
                                    }
                                }
                                else if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Percentage)
                                {
                                    discountAmount = (decimal)(((currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets) * (decimal)discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValue) / 100);
                                    if (discountAmount == (currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets))
                                    {
                                        currentTransactionDetail.ConvenienceCharges = 0;
                                        currentTransactionDetail.ServiceCharge      = 0;
                                    }
                                }
                                totalDiscountAmount += discountAmount;

                                if (command.Channel == Contracts.Enums.Channels.Feel)
                                {
                                    var eventTicketAttribute = _eventTicketAttributeRepository.Get(currentTransactionDetail.EventTicketAttributeId);
                                    var eventCurreny         = _currencyTypeRepository.Get(eventTicketAttribute.CurrencyId);
                                    var targetCurrency       = _currencyTypeRepository.Get(transaction.CurrencyId);
                                    if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat)
                                    {
                                        discountAmount      = _geoCurrency.GetConvertedDiscountAmount((Decimal)discountAmount, eventCurreny.Id, targetCurrency.Code);
                                        totalDiscountAmount = _geoCurrency.GetConvertedDiscountAmount((Decimal)totalDiscountAmount, eventCurreny.Id, targetCurrency.Code);
                                    }
                                }
                                currentTransactionDetail.DiscountAmount = discountAmount;
                                _transactionDetailRepository.Save(currentTransactionDetail);
                            }
                        }
                    }
                }
            }

            ApplyDiscountCommandResult applyDiscountCommandResult = new ApplyDiscountCommandResult();

            if (totalDiscountAmount == 0)
            {
                applyDiscountCommandResult.Id = 0;
            }
            else
            {
                transaction.DiscountAmount  = totalDiscountAmount;
                transaction.NetTicketAmount = transaction.NetTicketAmount - totalDiscountAmount;
                if (transaction.GrossTicketAmount == totalDiscountAmount)
                {
                    transaction.NetTicketAmount    = 0;
                    transaction.ConvenienceCharges = 0;
                    transaction.ServiceCharge      = 0;
                }
                transaction.DiscountCode = command.Promocode;
                _transactionRepository.Save(transaction);

                applyDiscountCommandResult.Id                 = transaction.Id;
                applyDiscountCommandResult.CurrencyId         = transaction.CurrencyId;
                applyDiscountCommandResult.GrossTicketAmount  = transaction.GrossTicketAmount;
                applyDiscountCommandResult.DeliveryCharges    = transaction.DeliveryCharges;
                applyDiscountCommandResult.ConvenienceCharges = transaction.ConvenienceCharges;
                applyDiscountCommandResult.ServiceCharge      = transaction.ServiceCharge;
                applyDiscountCommandResult.DiscountAmount     = transaction.DiscountAmount;
                applyDiscountCommandResult.NetTicketAmount    = transaction.NetTicketAmount;
            }

            try
            {
                if (transaction.NetTicketAmount <= 0)
                {
                    var liveOnlineTransactionDetailModel = _transactionRepository.GetFeelOnlineDetails(transaction.Id).FirstOrDefault();
                    if (liveOnlineTransactionDetailModel != null)
                    {
                        //check if subcategory is LiveOnline
                        var eventCategoryModel = _eventCategoryRepository.Get(Convert.ToInt16(liveOnlineTransactionDetailModel.EventcategoryId));
                        var eventModel         = _eventRepository.Get(liveOnlineTransactionDetailModel.EventId);
                        if ((eventCategoryModel != null && eventModel.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && command.Channel == Contracts.Enums.Channels.Feel) || eventModel.EventCategoryId == 119)
                        {
                            _zoomMeetingProvider.CreateMeeting(transaction, true);
                            applyDiscountCommandResult.IsPaymentBypass = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
            }

            return(Task.FromResult <ICommandResult>(applyDiscountCommandResult));
        }
예제 #6
0
        public void BookSeats(long transactionId, Guid modifiedBy)
        {
            try
            {
                var transaction = _transactionRepository.Get(transactionId);
                try
                {
                    if (transaction != null)
                    {
                        var matchSeatTicketDetails = _matchSeatTicketDetailRepository.GetByTransactionId(transactionId);
                        if (matchSeatTicketDetails == null)
                        {
                            var transactionDetailList  = _transactionDetailRepository.GetByTransactionId(transaction.Id);
                            var transactionDetailModel = AutoMapper.Mapper.Map <IEnumerable <TransactionDetail> >(transactionDetailList);
                            var BarcodeNumber          = "";
                            foreach (var transactionDetail in transactionDetailModel)
                            {
                                var eventTicketAttributes      = _eventTicketAttributeRepository.Get(transactionDetail.EventTicketAttributeId);
                                var eventTicketDetails         = _eventTicketDetailRepository.Get(eventTicketAttributes.EventTicketDetailId);
                                var eventDetails               = _eventDetailRepository.Get(eventTicketDetails.EventDetailId);
                                var transactionSeatDetails     = _transactionSeatDetailRepository.GetByTransactionDetailId(transactionDetail.Id);
                                var transactionSeatDeatilsList = AutoMapper.Mapper.Map <List <TransactionSeatDetail> >(transactionSeatDetails);

                                if (transactionSeatDeatilsList.Any())
                                {
                                    foreach (var item in transactionSeatDeatilsList)
                                    {
                                        Random rd = new Random();
                                        BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                        int    uniqueIdLength = 4;
                                        string uniqueIdChars  = "1234567890";
                                        char[] uniqueIdChar   = new char[uniqueIdLength];
                                        for (int j = 0; j < uniqueIdLength; j++)
                                        {
                                            uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                        }
                                        string uniqueId = new string(uniqueIdChar);
                                        MatchSeatTicketDetail matchSeatTicketDetail = _matchSeatTicketDetailRepository.Get(item.MatchSeatTicketDetailId);
                                        matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                        matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                        matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                        matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                        matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                        matchSeatTicketDetail.TicketTypeId  = (TicketType)transactionDetail.TicketTypeId;
                                        matchSeatTicketDetail.ChannelId     = Channels.Website;
                                        _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                    }
                                }
                                else
                                {
                                    if (transactionDetail.TotalTickets > 0)
                                    {
                                        if (transactionDetail.EventTicketAttributeId == 1657017 || transactionDetail.EventTicketAttributeId == 1657022 || transactionDetail.EventTicketAttributeId == 1657039 || transactionDetail.EventTicketAttributeId == 1657042) // For 2 adults and 2 child
                                        {
                                            MatchSeatTicketDetail matchSeatTicketDetail = new MatchSeatTicketDetail();
                                            for (int i = 1; i <= transactionDetail.TotalTickets * 2; i++)
                                            {
                                                Random rd = new Random();
                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);
                                                matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = TicketType.Regular;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                            for (int i = 1; i <= transactionDetail.TotalTickets * 2; i++)
                                            {
                                                Random rd = new Random();
                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);
                                                matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = TicketType.Child;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                        }
                                        else if (transactionDetail.EventTicketAttributeId == 1657018 || transactionDetail.EventTicketAttributeId == 1657040) //1 adult 3 child
                                        {
                                            for (int i = 1; i <= transactionDetail.TotalTickets * 1; i++)
                                            {
                                                Random rd = new Random();
                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);
                                                MatchSeatTicketDetail matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = TicketType.Regular;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                            for (int i = 1; i <= transactionDetail.TotalTickets * 3; i++)
                                            {
                                                Random rd = new Random();
                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);
                                                MatchSeatTicketDetail matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = TicketType.Child;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                        }
                                        else if (transactionDetail.EventTicketAttributeId == 1657038) //2 day vip pass
                                        {
                                            for (int i = 1; i <= transactionDetail.TotalTickets * 4; i++)
                                            {
                                                Random rd = new Random();
                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);
                                                MatchSeatTicketDetail matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = TicketType.Regular;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                        }
                                        else
                                        {
                                            for (int i = 1; i <= transactionDetail.TotalTickets; i++)
                                            {
                                                Random rd = new Random();
                                                MatchSeatTicketDetail matchSeatTicketDetail = new MatchSeatTicketDetail();

                                                BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");
                                                int    uniqueIdLength = 4;
                                                string uniqueIdChars  = "1234567890";
                                                char[] uniqueIdChar   = new char[uniqueIdLength];
                                                for (int j = 0; j < uniqueIdLength; j++)
                                                {
                                                    uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)];
                                                }
                                                string uniqueId = new string(uniqueIdChar);

                                                if (eventTicketDetails != null)
                                                {
                                                    matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByEventTicketDetailsId(eventTicketDetails.Id);
                                                }
                                                matchSeatTicketDetail.BarcodeNumber = BarcodeNumber + "0" + ((short)Channels.Website).ToString() + matchSeatTicketDetail.MatchLayoutSectionSeatId + uniqueId;
                                                matchSeatTicketDetail.Price         = transactionDetail.PricePerTicket;
                                                matchSeatTicketDetail.SeatStatusId  = SeatStatus.Sold;
                                                matchSeatTicketDetail.TransactionId = transactionDetail.TransactionId;
                                                matchSeatTicketDetail.ModifiedBy    = modifiedBy;
                                                matchSeatTicketDetail.TicketTypeId  = (TicketType)transactionDetail.TicketTypeId;
                                                matchSeatTicketDetail.ChannelId     = Channels.Website;
                                                _matchSeatTicketDetailRepository.Save(matchSeatTicketDetail);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, ex);
                }
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
            }
        }
예제 #7
0
        public CheckoutCommandResult SaveTransaction(CheckoutCommand checkoutCommand, IEnumerable <Contracts.Models.EventTicketAttribute> eventTicketAttributeModel, FIL.Contracts.DataModels.User user)
        {
            try
            {
                var isPaymentBypass = false;
                var StripeAccount   = FIL.Contracts.Enums.StripeAccount.None;
                List <TransactionDetail> transactionDetailList             = new List <TransactionDetail>();
                List <FIL.Contracts.Models.CartItemModel> lstEventDetailId = new List <FIL.Contracts.Models.CartItemModel>();
                FIL.Contracts.DataModels.Transaction      transaction      = new FIL.Contracts.DataModels.Transaction();

                decimal grossTicketAmount = 0;
                long    eventDetailId = 0, ticketCategoryId = 0;
                decimal netTicketAmount     = 0;
                decimal totalDiscountAmount = 0;

                if (checkoutCommand.IsASI == null)
                {
                    checkoutCommand.IsASI = false;
                }

                var allETD = _eventTicketDetailRepository.GetByEventTicketDetailsIds(eventTicketAttributeModel.Select(s => s.EventTicketDetailId).Distinct()).Distinct();
                var allED  = _eventDetailRepository.GetByIds(allETD.Select(s => s.EventDetailId).Distinct()).Distinct();
                foreach (Contracts.Commands.Transaction.EventTicketAttribute ticketAttributes in checkoutCommand.EventTicketAttributeList)
                {
                    var     currentTA = ticketAttributes;
                    var     transactionType = checkoutCommand.IsQrTransaction ? TransactionType.QRCode : checkoutCommand.TransactionType == TransactionType.Itinerary ? TransactionType.Itinerary : ticketAttributes.TicketType == TicketType.SeasonPackage ? TransactionType.Season : ticketAttributes.TransactionType == TransactionType.LiveOnline ? TransactionType.LiveOnline : ticketAttributes.TransactionType == TransactionType.AddOns ? TransactionType.AddOns : TransactionType.Regular;
                    decimal discountAmount = 0, donationAmount = 0;
                    if (ticketAttributes.DiscountedPrice > 0)
                    {
                        discountAmount = ticketAttributes.DiscountedPrice;
                    }
                    if (ticketAttributes.DonationAmount != null && ticketAttributes.DonationAmount > 0)
                    {
                        donationAmount = (decimal)ticketAttributes.DonationAmount;
                    }
                    Contracts.Models.EventTicketAttribute checkoutCommandEventTicketAttribute = eventTicketAttributeModel.Where(w => w.Id == ticketAttributes.Id).FirstOrDefault();
                    decimal           pricePerTicket    = checkoutCommandEventTicketAttribute.Price;
                    EventTicketDetail eventTicketDetail = allETD.Where(s => s.Id == checkoutCommandEventTicketAttribute.EventTicketDetailId && s.IsEnabled).FirstOrDefault();
                    if (eventTicketDetail != null)
                    {
                        EventDetail eventDetail = allED.Where(s => s.Id == eventTicketDetail.EventDetailId && s.IsEnabled).FirstOrDefault();
                        if (eventDetail != null)
                        {
                            var visitStartDate = ticketAttributes.VisitDate;
                            var visitEndDate   = ticketAttributes.VisitDate;
                            if (checkoutCommand.TransactionType == TransactionType.Itinerary)
                            {
                                visitStartDate = ticketAttributes.VisitStartTime.Split(":").Count() > 1 ? new DateTime(visitStartDate.Year, visitStartDate.Month, visitStartDate.Day, Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[1]), 0) : visitStartDate;
                                visitEndDate   = ticketAttributes.VisitEndTime.Split(":").Count() > 1 ? new DateTime(visitEndDate.Year, visitEndDate.Month, visitEndDate.Day, Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[1]), 0) : visitEndDate;
                            }
                            visitStartDate = visitStartDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitStartDate;
                            visitEndDate   = visitEndDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitEndDate;
                            if ((bool)checkoutCommand.IsASI)
                            {
                                pricePerTicket = ticketAttributes.TicketType == TicketType.Child ? 0 : checkoutCommandEventTicketAttribute.Price;
                            }
                            if (ticketAttributes.OverridedAmount != null && checkoutCommand.IsBSPUpgrade && ticketAttributes.OverridedAmount != 0)
                            {
                                pricePerTicket = (decimal)ticketAttributes.OverridedAmount;
                            }
                            if (ticketAttributes.TicketType == TicketType.SeasonPackage)
                            {
                                eventDetailId = eventTicketDetail.EventDetailId;
                                lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel {
                                    EventDetailId = eventDetailId
                                });
                                ticketCategoryId = eventTicketDetail.TicketCategoryId;
                                IEnumerable <EventDetail>       seasonEventDetails       = _eventDetailRepository.GetSeasonEventDetails(eventDetail.EventId, eventDetail.VenueId).Where(s => s.IsEnabled == true);
                                IEnumerable <EventTicketDetail> seasonEventTicketDetails = _eventTicketDetailRepository.GetByEventDetailIds(seasonEventDetails.Select(s => s.Id).Distinct()).Where(w => w.TicketCategoryId == eventTicketDetail.TicketCategoryId);
                                List <Contracts.DataModels.EventTicketAttribute> seasonEventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(seasonEventTicketDetails.Select(s => s.Id).Distinct()).Where(W => W.IsEnabled == true && W.SeasonPackage == true).ToList();
                                var seasonPrice = seasonEventTicketAttributes[0].SeasonPackagePrice;
                                pricePerTicket = seasonPrice / seasonEventTicketAttributes.Count;
                            }
                            else
                            {
                                eventDetailId = eventDetail.Id;
                                lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel {
                                    EventDetailId = eventTicketDetail.EventDetailId
                                });
                                ticketCategoryId = eventTicketDetail.TicketCategoryId;
                            }

                            if (Convert.ToInt16(ticketAttributes.TotalTickets) <= checkoutCommandEventTicketAttribute.RemainingTicketForSale)
                            {
                                TransactionDetail transactionDetail = new TransactionDetail();
                                transactionDetail.EventTicketAttributeId = ticketAttributes.Id;
                                transactionDetail.TotalTickets           = Convert.ToInt16(ticketAttributes.TotalTickets);
                                transactionDetail.PricePerTicket         = checkoutCommand.TransactionType == TransactionType.Itinerary ? ticketAttributes.Price : pricePerTicket;
                                transactionDetail.DiscountAmount         = discountAmount;
                                transactionDetail.VisitDate       = visitStartDate;
                                transactionDetail.VisitEndDate    = visitEndDate;
                                transactionDetail.TransactionType = transactionType;
                                transactionDetail.TicketTypeId    = checkoutCommand.TransactionType == TransactionType.Itinerary ? (short)(ticketAttributes.IsAdult ? 10 : 2) : (short)(TicketType)ticketAttributes.TicketType;
                                if (checkoutCommand.ReferralId != null)
                                {
                                    var referral = _referralProvider.GetReferral(checkoutCommand.ReferralId, eventDetail.EventId, checkoutCommand.ModifiedBy);
                                    if (referral != null && referral.Id != 0)
                                    {
                                        transactionDetail.ReferralId = referral.Id;
                                    }
                                }
                                if (checkoutCommand.ChannelId == Channels.Feel && checkoutCommand.TransactionType != TransactionType.Itinerary)
                                {
                                    _geoCurrency.UpdateTransactionUpdates(transactionDetail, checkoutCommand.TargetCurrencyCode, checkoutCommandEventTicketAttribute.CurrencyId);
                                }
                                if (donationAmount > 0) // Donation doesn't need the local currency as the amount itself in the local currency
                                {
                                    transactionDetail.PricePerTicket = transactionDetail.PricePerTicket + donationAmount;
                                }
                                netTicketAmount               += ((ticketAttributes.TotalTickets * (decimal)transactionDetail.PricePerTicket) - ((decimal)transactionDetail.DiscountAmount));
                                grossTicketAmount             += ((ticketAttributes.TotalTickets * transactionDetail.PricePerTicket));
                                totalDiscountAmount           += (decimal)transactionDetail.DiscountAmount;
                                transactionDetail.MembershipId = ticketAttributes.MembershipId;
                                transactionDetailList.Add(transactionDetail);
                            }
                            else
                            {
                                EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                                Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                                return(new CheckoutCommandResult
                                {
                                    Id = 0,
                                    Success = false,
                                    EventName = eventDetails.Name,
                                    TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                                    IsTransactionLimitExceed = false,
                                    IsTicketCategorySoldOut = true
                                });
                            }
                        }
                        else
                        {
                            EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                            Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                            return(new CheckoutCommandResult
                            {
                                Id = 0,
                                Success = false,
                                EventName = eventDetails.Name,
                                TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                                IsTransactionLimitExceed = false,
                                IsTicketCategorySoldOut = true
                            });
                        }
                    }
                    else
                    {
                        EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                        Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                        return(new CheckoutCommandResult
                        {
                            Id = 0,
                            Success = false,
                            EventName = eventDetails.Name,
                            TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                            IsTransactionLimitExceed = false,
                            IsTicketCategorySoldOut = true
                        });
                    }
                }
                var intialCurrencyId = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault();
                var currencyId       = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault();
                if (checkoutCommand.ChannelId == Channels.Feel) // Update the currencyId
                {
                    if (checkoutCommand.TransactionType == TransactionType.Itinerary)
                    {
                        currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TransactionCurrency).Id;
                    }
                    else
                    {
                        currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TargetCurrencyCode).Id;
                    }
                }

                /*if (checkoutCommand.ISRasv) // NAB test bed
                 * {
                 * var splitprice = netTicketAmount.ToString("0.00").Split(".");
                 *  var price = splitprice[0] + ".00";
                 * netTicketAmount = Convert.ToDecimal(netTicketAmount);
                 * }*/

                transaction.ChannelId           = checkoutCommand.ChannelId;
                transaction.CurrencyId          = currencyId;
                transaction.TotalTickets        = Convert.ToInt16(checkoutCommand.EventTicketAttributeList.Sum(s => s.TotalTickets));
                transaction.GrossTicketAmount   = grossTicketAmount;
                transaction.NetTicketAmount     = netTicketAmount;
                transaction.DiscountAmount      = totalDiscountAmount;
                transaction.TransactionStatusId = TransactionStatus.UnderPayment;
                transaction.FirstName           = user.FirstName;
                transaction.LastName            = user.LastName;
                transaction.PhoneCode           = user.PhoneCode;
                transaction.PhoneNumber         = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.PhoneNumber;
                transaction.EmailId             = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.Email;
                transaction.CountryName         = !string.IsNullOrWhiteSpace(user.PhoneCode) ? _countryRepository.GetByPhoneCode(user.PhoneCode).Name : "India";
                transaction.CreatedBy           = user.AltId;
                transaction.CreatedUtc          = DateTime.UtcNow;

                try
                {
                    var ipDetail = _saveIPProvider.SaveIp(checkoutCommand.Ip);
                    if (ipDetail != null && ipDetail.Id > 0)
                    {
                        transaction.IPDetailId = ipDetail.Id;
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                    transaction.IPDetailId = 1;
                }

                transaction.ModifiedBy = user.AltId;
                transaction.AltId      = Guid.NewGuid();
                if (transaction.CurrencyId != 7)
                {
                    transaction.OTP = checkoutCommand.OTPCode;
                }
                if (checkoutCommand.DonationAmount != null && checkoutCommand.DonationAmount != 0)
                {
                    transaction.DonationAmount = checkoutCommand.DonationAmount;
                }

                FIL.Contracts.DataModels.Transaction transactionResult = _transactionRepository.Save(transaction);
                foreach (TransactionDetail transactionDetail in transactionDetailList)
                {
                    transactionDetail.TransactionId = transactionResult.Id;
                    var currentTransactionDetail = _transactionDetailRepository.Save(transactionDetail);
                    FIL.Contracts.DataModels.EventTicketAttribute eventTicketAttribute = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketAttribute>(_eventTicketAttributeRepository.Get(transactionDetail.EventTicketAttributeId));
                    FIL.Contracts.DataModels.EventTicketDetail    eventTicketDetail    = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketDetail>(_eventTicketDetailRepository.Get(eventTicketAttribute.EventTicketDetailId));
                    if (Convert.ToInt16(transactionDetail.TotalTickets) <= eventTicketAttribute.RemainingTicketForSale)
                    {
                        eventTicketAttribute.RemainingTicketForSale -= transactionDetail.TotalTickets;
                        _eventTicketAttributeRepository.Save(eventTicketAttribute);
                        if (checkoutCommand.ChannelId == Channels.Website)
                        {
                            if (eventTicketDetail.InventoryTypeId == InventoryType.Seated || eventTicketDetail.InventoryTypeId == InventoryType.SeatedWithSeatSelection || eventTicketDetail.InventoryTypeId == InventoryType.NoneSeated)
                            {
                                List <Contracts.Models.TMS.SeatDetail> seatDetail = new List <Contracts.Models.TMS.SeatDetail>();
                                if (checkoutCommand.SeatDetails != null)
                                {
                                    seatDetail = AutoMapper.Mapper.Map <List <Contracts.Models.TMS.SeatDetail> >(checkoutCommand.SeatDetails.Where(w => w.EventTicketDetailId == eventTicketDetail.Id));
                                }
                                else
                                {
                                    seatDetail = null;
                                }
                                var seatBlock = _seatBlockingProvider.BlockSeat(seatDetail, transactionDetail, eventTicketAttribute, eventTicketDetail, user.AltId, Channels.Website);
                                if (!seatBlock.Success && seatBlock.IsSeatSoldOut)
                                {
                                    return(new CheckoutCommandResult
                                    {
                                        Success = false,
                                        Id = 0,
                                        TransactionAltId = Guid.NewGuid(),
                                        IsTransactionLimitExceed = false,
                                        IsTicketCategorySoldOut = false,
                                        IsSeatSoldOut = true
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                        Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                        return(new CheckoutCommandResult
                        {
                            Id = 0,
                            Success = false,
                            EventName = eventDetails.Name,
                            TicketCategoryName = transactionDetail.TicketTypeId == (short)TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                            IsTransactionLimitExceed = false,
                            IsTicketCategorySoldOut = true
                        });
                    }
                    /* Save Transaction Schedule Detail */
                    var currentTicket = checkoutCommand.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault();
                    if (currentTicket.ScheduleDetailId != null && currentTicket.ScheduleDetailId != 0)
                    {
                        _saveTransactionScheduleDetailProvider.SaveTransactionScheduleDetail(currentTransactionDetail.Id, (long)currentTicket.ScheduleDetailId);
                    }
                }

                try
                {
                    if (checkoutCommand.ChannelId == Channels.Feel || checkoutCommand.ChannelId == Channels.Website) // If Live Online Transaction with 0.00 price
                    {
                        var @event = _eventRepository.Get(allED.FirstOrDefault().EventId);
                        if (@event != null)
                        {
                            if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && transaction.NetTicketAmount == 0)
                            {
                                _zoomMeetingProvider.CreateMeeting(transaction, true);
                                isPaymentBypass = true;
                            }
                            else if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online)
                            {
                                StripeAccount = _eventStripeConnectAccountProvider.GetEventStripeAccount(allED.FirstOrDefault().EventId, checkoutCommand.ChannelId);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                }
                try
                {
                    /*Check if referred transactionId already upgraded to BSP or successfull transaction, if yes then don't allow another transaction using same referral/ transaction id*/
                    if (checkoutCommand.IsBSPUpgrade && checkoutCommand.ReferralId != null)
                    {
                        var transactions = _transactionRepository.GetAllSuccessfulTransactionByReferralId(checkoutCommand.ReferralId);
                        if (transactions.Any())
                        {
                            return(new CheckoutCommandResult
                            {
                                Id = 0,
                                Success = false,
                                IsBSPUpgraded = true
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                }

                return(new CheckoutCommandResult
                {
                    Id = transactionResult.Id,
                    CartBookingModel = lstEventDetailId,
                    Transaction = transactionResult,
                    IsPaymentByPass = isPaymentBypass,
                    Success = true,
                    StripeAccount = StripeAccount,
                });
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
                return(new CheckoutCommandResult
                {
                });
            }
        }
예제 #8
0
        protected override async Task <ICommandResult> Handle(CreateBookingCommand command)
        {
            CreateBookingCommandResult results = new CreateBookingCommandResult();
            var        transaction             = _transactionRepository.Get(command.TransactionId);
            var        transactionDetail       = _transactionDetailRepository.GetByTransactionId(command.TransactionId);
            RootObject rootObject = new RootObject();

            if (transaction != null)
            {
                IDictionary <string, long> ticketCategoryValues = new Dictionary <string, long>();
                var feelBarcodemapping = _feelBarcodeMappingRepository.GetByTransactionDetailIds(transactionDetail.Select(s => s.Id)).ToList();
                if (feelBarcodemapping.Count() == 0)
                {
                    var transactionDetailModel = AutoMapper.Mapper.Map <IEnumerable <TransactionDetail> >(transactionDetail);
                    GetBarcodeResponseViewModel           getBarcodeResponseViewModel = new GetBarcodeResponseViewModel();
                    FIL.Contracts.Models.FeelBarcode.Data data = new FIL.Contracts.Models.FeelBarcode.Data();
                    Address     address     = new Address();
                    Contact     contact     = new Contact();
                    BookingType bookingType = new BookingType();
                    List <FIL.Contracts.Models.FeelBarcode.BookingDetail> bookingDetails = new List <FIL.Contracts.Models.FeelBarcode.BookingDetail>();
                    foreach (var transactiondetail in transactionDetailModel)
                    {
                        var eventTicketAttributes        = _eventTicketAttributeRepository.Get(transactiondetail.EventTicketAttributeId);
                        var eventTicketDetails           = _eventTicketDetailRepository.Get(eventTicketAttributes.EventTicketDetailId);
                        var eventDetails                 = _eventDetailRepository.Get(eventTicketDetails.EventDetailId);
                        var currentTransaction           = _transactionRepository.Get(transaction.Id);
                        var currentTransactionDetail     = _transactionDetailRepository.Get(transactiondetail.Id);
                        var currentEventTicketAttributes = _eventTicketAttributeRepository.Get((int)currentTransactionDetail.EventTicketAttributeId);
                        var currentEventTicketDetail     = _eventTicketDetailRepository.Get(currentEventTicketAttributes.EventTicketDetailId);
                        var currentTicketCategory        = _ticketCategoryRepository.Get((int)currentEventTicketDetail.TicketCategoryId);
                        var currentEventDetails          = _eventDetailRepository.Get(currentEventTicketDetail.EventDetailId);
                        var curretVenue         = _venueRepository.Get(currentEventDetails.VenueId);
                        var currentCity         = _cityRepository.Get(curretVenue.CityId);
                        var currentstate        = _stateRepository.Get(currentCity.StateId);
                        var currentcountry      = _countryRepository.Get(currentstate.CountryId);
                        var currentEvent        = _eventRepository.Get(currentEventDetails.EventId);
                        var currentCurrencyType = _currencyTypeRepository.Get(currentEventTicketAttributes.CurrencyId);

                        if (currentEvent.EventSourceId == EventSource.CitySightSeeing)
                        {
                            ticketCategoryValues.Add(currentTicketCategory.Name.ToLower(), transactiondetail.Id);
                            var      fromDate   = Convert.ToDateTime(transactiondetail.VisitDate).ToUniversalTime();
                            DateTime localTime1 = fromDate;
                            DateTime endDate    = DateTime.Now;
                            localTime1 = DateTime.SpecifyKind(localTime1, DateTimeKind.Local);
                            DateTimeOffset localTime2 = localTime1;
                            var            mystring   = localTime2.ToString();
                            var            offset     = mystring.Substring(mystring.Length - 6);
                            var            citySightSeeingEventDetailMapping             = _citySightSeeingEventDetailMappingRepository.GetByEventDetailId(currentEventDetails.Id);
                            var            citySightSeeingtickets                        = _citySightSeeingTicketRepository.Get(citySightSeeingEventDetailMapping.CitySightSeeingTicketId);
                            FIL.Contracts.Models.FeelBarcode.BookingDetail bookingDetail = new FIL.Contracts.Models.FeelBarcode.BookingDetail();
                            var citySightSeeingTicketDetails     = _citySightSeeingTicketDetailRepository.GetByTicketId(citySightSeeingtickets.TicketId);
                            var bookingDistributorReference      = RandomDigits(10);
                            var citySightSeeingTransactionDetail = new CitySightSeeingTransactionDetail();
                            if (citySightSeeingTicketDetails.TicketClass != 1)
                            {
                                citySightSeeingTransactionDetail = _citySightSeeingTransactionDetailRepository.GetByTransactionId(transactiondetail.TransactionId);
                                bookingType.from_date_time       = citySightSeeingTransactionDetail.FromDateTime;
                                bookingType.to_date_time         = citySightSeeingTransactionDetail.EndDateTime;
                                data.reservation_reference       = citySightSeeingTransactionDetail.ReservationReference;
                            }

                            var citySightSeeingLocations = _citySightSeeingLocationRepository.Get(citySightSeeingtickets.CitySightSeeingLocationId);

                            var locationDetail = await _googleMapApi.GetLatLongFromAddress(citySightSeeingLocations.Name);

                            string tz = ""; DateTime fromDateTime = DateTime.Now;; var offsetTime = "";
                            var    duration = citySightSeeingTicketDetails.Duration;
                            double lat      = Convert.ToDouble(locationDetail.Result.lat);
                            double lng      = Convert.ToDouble(locationDetail.Result.lng);
                            tz = TimeZoneLookup.GetTimeZone(lat, lng).Result;
                            TimeZoneInfo tzi           = TZConvert.GetTimeZoneInfo(tz);
                            var          visitDateTime = Convert.ToDateTime(transactiondetail.VisitDate);
                            var          timeSlot      = citySightSeeingTicketDetails.TicketClass == 1 ? "00:00" : citySightSeeingTransactionDetail.TimeSlot;
                            var          utcOffset     = tzi.BaseUtcOffset.ToString().Split(":")[0];
                            if (utcOffset.Contains("-"))
                            {
                                offset = utcOffset;
                            }
                            else
                            {
                                offset = "+" + utcOffset;
                            }
                            var formattedDateTime = visitDateTime.Year + "-" + visitDateTime.Month + "-" + visitDateTime.Day + "T" + timeSlot;
                            fromDate = Convert.ToDateTime(formattedDateTime);
                            if (duration.Contains("day"))
                            {
                                string[] day = duration.Split("day");
                                endDate = fromDate.AddDays(Convert.ToDouble(day[0]));
                            }
                            if (duration.Contains("hour"))
                            {
                                string[] hour = duration.Split("hour");
                                endDate = fromDate.AddHours(Convert.ToDouble(hour[0]));
                            }
                            var formattedEndDate = endDate.Year + "-" + endDate.Month + "-" + endDate.Day + "T" + endDate.TimeOfDay.ToString();
                            bookingType.from_date_time  = formattedDateTime + offset;
                            bookingType.to_date_time    = formattedEndDate + offset;
                            bookingDetail.ticket_type   = (currentTicketCategory.Name).ToUpper();
                            bookingDetail.count         = currentTransactionDetail.TotalTickets;
                            bookingDetail.extra_options = null;
                            bookingDetails.Add(bookingDetail);

                            bookingType.ticket_id = citySightSeeingTicketDetails.TicketId;
                            address.street        = curretVenue.Name;
                            address.postal_code   = "432243";
                            address.city          = currentCity.Name;

                            contact.address             = address;
                            contact.phonenumber         = currentTransaction.PhoneNumber;
                            data.currency               = currentCurrencyType.Code;
                            bookingType.booking_details = bookingDetails;
                            data.distributor_id         = _settings.GetConfigSetting <string>(SettingKeys.Integration.CitySightSeeing.DistributorId);
                            data.booking_type           = bookingType;
                            data.booking_name           = transaction.FirstName;
                            data.booking_email          = transaction.EmailId;
                            data.contact               = contact;
                            data.notes                 = null;
                            data.product_language      = "en";
                            data.distributor_reference = bookingDistributorReference;
                            rootObject.request_type    = "booking";
                            rootObject.data            = data;
                            var responeBooking = await GetBarcodeAsync(rootObject, transaction.Id, ticketCategoryValues);

                            if (responeBooking.data != null)
                            {
                                if (citySightSeeingTicketDetails.TicketClass != 1)
                                {
                                    citySightSeeingTransactionDetail.BookingReference            = responeBooking.data.booking_reference;
                                    citySightSeeingTransactionDetail.BookingDistributorReference = responeBooking.data.distributor_reference;
                                    citySightSeeingTransactionDetail.IsOrderConfirmed            = true;
                                    _citySightSeeingTransactionDetailRepository.Save(citySightSeeingTransactionDetail);
                                }
                                else
                                {
                                    _citySightSeeingTransactionDetailRepository.Save(new CitySightSeeingTransactionDetail
                                    {
                                        AltId                       = Guid.NewGuid(),
                                        FromDateTime                = fromDate.ToString() + offset,
                                        EndDateTime                 = endDate.ToString() + offset,
                                        HasTimeSlot                 = false,
                                        BookingReference            = responeBooking.data.booking_reference,
                                        BookingDistributorReference = bookingDistributorReference,
                                        TicketId                    = citySightSeeingtickets.TicketId,
                                        TransactionId               = command.TransactionId,
                                        IsOrderConfirmed            = true,
                                        ModifiedBy                  = command.ModifiedBy
                                    });
                                }
                                results.Success = true;
                                return(results);
                            }
                            else
                            {
                                results.Success = false;
                                return(results);
                            }
                        }
                    }
                }
                else
                {
                    results.IsExists = true;
                    return(results);
                }
            }
            else
            {
                results.Success = false;
                return(results);
            }
            return(results);
        }