Пример #1
0
        public IActionResult Get(long id)
        {
            EventDetail EventDetail = _EventDetailRepository.Get(id);

            if (EventDetail == null)
            {
                return(NotFound("The EventDetail couldn't be found."));
            }

            return(Ok(EventDetail));
        }
Пример #2
0
        public TiqetProductUploadQueryResult Handle(TiqetProductUploadQuery query)
        {
            var tiqetProducts = _tiqetProductRepository.GetAll().Skip(query.SkipIndex).Take(query.TakeIndex).ToList();
            List <TiqetImageModel> tiqetImageModelList = new List <TiqetImageModel>();

            foreach (var currentProduct in tiqetProducts)
            {
                try
                {
                    TiqetImageModel tiqetImageModel  = new TiqetImageModel();
                    var             tiqetImage       = _tiqetProductImageRepository.GetByProductId(currentProduct.ProductId).FirstOrDefault();
                    var             tiqetEventDetail = _tiqetEventDetailMappingRepository.GetByProductId(currentProduct.ProductId);
                    var             eventDetail      = _eventDetailRepository.Get(tiqetEventDetail.EventDetailId);
                    var             eventId          = _eventRepository.Get(eventDetail.EventId);
                    tiqetImageModel.EventAltId = eventId.AltId;
                    tiqetImageModel.ImageLink  = tiqetImage.Large;
                    tiqetImageModelList.Add(tiqetImageModel);
                }
                catch (Exception e)
                {
                    continue;
                }
            }

            return(new TiqetProductUploadQueryResult
            {
                TiqetImagesList = tiqetImageModelList
            });
        }
Пример #3
0
 protected override async Task Handle(DisabledCitySightSeeingEventCommand command)
 {
     try
     {
         //for disabling eventdetails & events
         var getDisabledCitySightEventDetails = _citySightSeeingEventDetailMappingRepository.GetAllDisabledDetails();
         var getDisabledEventDetails          = _eventDetailRepository.GetByEventDetailIds(getDisabledCitySightEventDetails.Select(s => s.EventDetailId));
         var getDisabledEventDetailsModel     = AutoMapper.Mapper.Map <IEnumerable <EventDetail> >(getDisabledEventDetails);
         foreach (var eventDetailData in getDisabledEventDetailsModel)
         {
             var disabledEventDetails = _eventDetailRepository.Get(eventDetailData.Id);
             disabledEventDetails.IsEnabled = false;
             _eventDetailRepository.Save(disabledEventDetails);
             var disabledEvent = _eventRepository.Get(disabledEventDetails.EventId);
             disabledEvent.IsEnabled = false;
             _eventRepository.Save(disabledEvent);
         }
     }
     catch (Exception e)
     {
         _logger.Log(LogCategory.Error, new Exception("Failed to Disable Event HOHO Data", e));
     }
 }
Пример #4
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);
            }
        }
Пример #5
0
        public CheckoutCommandResult BlockSeat(List <SeatDetail> seatData, TransactionDetail transactionDetail, FIL.Contracts.DataModels.EventTicketAttribute eventTicketAttribute, EventTicketDetail eventTicketDetail, Guid userAltId, Channels channelId)
        {
            try
            {
                CheckoutCommandResult checkoutCommandResult       = new CheckoutCommandResult();
                FIL.Contracts.DataModels.EventDetail eventDetails = _eventDetailRepository.Get(eventTicketDetail.EventDetailId);
                var BarcodeNumber = "";
                int seatCounter   = 0;
                if (eventTicketDetail.InventoryTypeId == InventoryType.Seated || eventTicketDetail.InventoryTypeId == InventoryType.SeatedWithSeatSelection)
                {
                    if (seatData != null)
                    {
                        foreach (var seat in seatData)
                        {
                            FIL.Contracts.DataModels.MatchLayoutSectionSeat matchLayoutSectionSeats = _matchLayoutSectionSeatRepository.Get(seat.MatchLayoutSectionSeatId);
                            if (matchLayoutSectionSeats != null && matchLayoutSectionSeats.SeatStatusId != SeatStatus.Sold)
                            {
                                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);
                                matchLayoutSectionSeats.Id           = matchLayoutSectionSeats.Id;
                                matchLayoutSectionSeats.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer;
                                matchLayoutSectionSeats.UpdatedUtc   = DateTime.UtcNow;
                                matchLayoutSectionSeats.UpdatedBy    = userAltId;
                                _matchLayoutSectionSeatRepository.Save(matchLayoutSectionSeats);

                                _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail
                                {
                                    AltId = Guid.NewGuid(),
                                    EventTicketDetailId      = eventTicketDetail.Id,
                                    MatchLayoutSectionSeatId = matchLayoutSectionSeats.Id,
                                    BarcodeNumber            = BarcodeNumber + "0" + (short)channelId + matchLayoutSectionSeats.Id + uniqueId,
                                    Price             = transactionDetail.PricePerTicket,
                                    TransactionId     = transactionDetail.TransactionId,
                                    ModifiedBy        = userAltId,
                                    TicketTypeId      = (TicketType)transactionDetail.TicketTypeId,
                                    SeatStatusId      = SeatStatus.Sold,
                                    PrintStatusId     = PrintStatus.NotPrinted,
                                    IsEnabled         = true,
                                    EntryCountAllowed = 1,
                                    ChannelId         = channelId,
                                });

                                seatCounter++;
                            }
                        }
                        if (seatData.Count == seatCounter)
                        {
                            checkoutCommandResult.Success       = true;
                            checkoutCommandResult.IsSeatSoldOut = false;
                        }
                        else
                        {
                            checkoutCommandResult.Success       = false;
                            checkoutCommandResult.IsSeatSoldOut = true;
                        }
                    }
                    else
                    {
                        List <FIL.Contracts.DataModels.MatchLayoutSectionSeat> matchLayoutSectionSeats = AutoMapper.Mapper.Map <List <FIL.Contracts.DataModels.MatchLayoutSectionSeat> >(_matchLayoutSectionSeatRepository.GetByEventTicketDetails(eventTicketDetail.Id, transactionDetail.TotalTickets));
                        if (matchLayoutSectionSeats.Count == transactionDetail.TotalTickets)
                        {
                            foreach (var seatItem in matchLayoutSectionSeats)
                            {
                                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);

                                if (seatItem.SeatStatusId == SeatStatus.UnSold && (seatItem.SeatTypeId == SeatType.Available || seatItem.SeatTypeId == SeatType.WheelChair))
                                {
                                    if (seatItem.SeatTypeId == SeatType.WheelChair)
                                    {
                                        var wheelChairSeat = _masterLayoutCompanionSeatMappingRepository.GetByWheelChairSeatId(seatItem.Id);
                                        if (wheelChairSeat != null)
                                        {
                                            seatItem.Id           = wheelChairSeat.CompanionSeatId;
                                            seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer;
                                            seatItem.ModifiedBy   = userAltId;
                                            _matchLayoutSectionSeatRepository.Save(seatItem);

                                            _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail
                                            {
                                                AltId = Guid.NewGuid(),
                                                EventTicketDetailId      = eventTicketDetail.Id,
                                                MatchLayoutSectionSeatId = wheelChairSeat.CompanionSeatId,
                                                BarcodeNumber            = BarcodeNumber + "0" + (short)channelId + wheelChairSeat.CompanionSeatId + uniqueId,
                                                Price             = transactionDetail.PricePerTicket,
                                                TransactionId     = transactionDetail.TransactionId,
                                                ModifiedBy        = userAltId,
                                                TicketTypeId      = (TicketType)transactionDetail.TicketTypeId,
                                                SeatStatusId      = SeatStatus.Sold,
                                                PrintStatusId     = PrintStatus.NotPrinted,
                                                IsEnabled         = true,
                                                EntryCountAllowed = 1,
                                                ChannelId         = channelId,
                                            });
                                        }

                                        seatItem.Id           = seatItem.Id;
                                        seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer;
                                        seatItem.ModifiedBy   = userAltId;
                                        _matchLayoutSectionSeatRepository.Save(seatItem);

                                        _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail
                                        {
                                            AltId = Guid.NewGuid(),
                                            EventTicketDetailId      = eventTicketDetail.Id,
                                            MatchLayoutSectionSeatId = seatItem.Id,
                                            BarcodeNumber            = BarcodeNumber + "0" + (short)channelId + seatItem.Id + uniqueId,
                                            Price             = transactionDetail.PricePerTicket,
                                            TransactionId     = transactionDetail.TransactionId,
                                            ModifiedBy        = userAltId,
                                            TicketTypeId      = (TicketType)transactionDetail.TicketTypeId,
                                            SeatStatusId      = SeatStatus.Sold,
                                            PrintStatusId     = PrintStatus.NotPrinted,
                                            IsEnabled         = true,
                                            EntryCountAllowed = 1,
                                            ChannelId         = channelId,
                                        });
                                    }
                                    else
                                    {
                                        seatItem.Id           = seatItem.Id;
                                        seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer;
                                        seatItem.ModifiedBy   = userAltId;
                                        _matchLayoutSectionSeatRepository.Save(seatItem);

                                        _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail
                                        {
                                            AltId = Guid.NewGuid(),
                                            EventTicketDetailId      = eventTicketDetail.Id,
                                            MatchLayoutSectionSeatId = seatItem.Id,
                                            BarcodeNumber            = BarcodeNumber + "0" + (short)channelId + seatItem.Id + uniqueId,
                                            Price             = transactionDetail.PricePerTicket,
                                            TransactionId     = transactionDetail.TransactionId,
                                            ModifiedBy        = userAltId,
                                            TicketTypeId      = (TicketType)transactionDetail.TicketTypeId,
                                            SeatStatusId      = SeatStatus.Sold,
                                            PrintStatusId     = PrintStatus.NotPrinted,
                                            IsEnabled         = true,
                                            EntryCountAllowed = 1,
                                            ChannelId         = channelId,
                                        });
                                    }
                                    seatCounter++;
                                }
                            }
                            if (seatCounter == transactionDetail.TotalTickets)
                            {
                                checkoutCommandResult.Success       = true;
                                checkoutCommandResult.IsSeatSoldOut = false;
                            }
                            else
                            {
                                checkoutCommandResult.Success       = false;
                                checkoutCommandResult.IsSeatSoldOut = true;
                            }
                        }
                        else
                        {
                            checkoutCommandResult.Success       = false;
                            checkoutCommandResult.IsSeatSoldOut = true;
                        }
                    }
                }
                else
                {
                    for (int i = 1; i <= transactionDetail.TotalTickets * 1; i++)
                    {
                        Random rd = new Random();
                        BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM");

                        int    uniqueIdLength = 14;
                        string uniqueIdChars  = "abcdefghijklmnopqrstuvwxyz1234567890";
                        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);

                        _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail
                        {
                            AltId = Guid.NewGuid(),
                            EventTicketDetailId = eventTicketDetail.Id,
                            BarcodeNumber       = BarcodeNumber + "0" + (short)channelId + uniqueId,
                            Price             = transactionDetail.PricePerTicket,
                            TransactionId     = transactionDetail.TransactionId,
                            ModifiedBy        = userAltId,
                            TicketTypeId      = (TicketType)transactionDetail.TicketTypeId,
                            SeatStatusId      = SeatStatus.Sold,
                            PrintStatusId     = PrintStatus.NotPrinted,
                            IsEnabled         = true,
                            EntryCountAllowed = 1,
                            ChannelId         = channelId,
                        });
                        seatCounter++;
                    }
                    if (seatCounter == transactionDetail.TotalTickets)
                    {
                        checkoutCommandResult.Success       = true;
                        checkoutCommandResult.IsSeatSoldOut = false;
                    }
                    else
                    {
                        checkoutCommandResult.Success       = false;
                        checkoutCommandResult.IsSeatSoldOut = true;
                    }
                }
                return(checkoutCommandResult);
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
                return(new CheckoutCommandResult
                {
                    Success = false,
                    IsSeatSoldOut = true
                });
            }
        }
Пример #6
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
            });
        }
        protected override async Task Handle(SaveEventScheduleCommand command)
        {
            foreach (var eventDetail in command.SubEventList)
            {
                var eventDetailData = new EventDetail();
                if (eventDetail.id == 0) // check for create or edit insert if 0
                {
                    eventDetailData = new FIL.Contracts.DataModels.EventDetail
                    {
                        Name          = eventDetail.name,
                        EventId       = eventDetail.eventId,
                        AltId         = Guid.NewGuid(),
                        VenueId       = eventDetail.venueId,
                        MetaDetails   = null,
                        Description   = eventDetail.Description,
                        GroupId       = 1,
                        StartDateTime = DateTime.Parse(eventDetail.startDateTime),
                        EndDateTime   = DateTime.Parse(eventDetail.endDateTime),
                        IsEnabled     = false,
                        CreatedUtc    = DateTime.UtcNow,
                        ModifiedBy    = command.userAltId
                    };
                    _eventDetailRepository.Save(eventDetailData);
                }
                else // update sub event
                {
                    eventDetailData               = _eventDetailRepository.Get(eventDetail.id);
                    eventDetailData.Name          = eventDetail.name;
                    eventDetailData.EventId       = eventDetail.eventId;
                    eventDetailData.VenueId       = eventDetail.venueId;
                    eventDetailData.Description   = eventDetail.Description;
                    eventDetailData.StartDateTime = DateTime.Parse(eventDetail.startDateTime);
                    eventDetailData.EndDateTime   = DateTime.Parse(eventDetail.endDateTime);
                    eventDetailData.ModifiedBy    = command.userAltId;
                    _eventDetailRepository.Save(eventDetailData);
                }

                //check for existing delivery type details
                var deliveryTypeData = _eventDeliveryTypeDetailRepository.GetByEventDetailId(eventDetailData.Id);
                if (deliveryTypeData.Count() > 0)
                {
                    foreach (var newDeliveryType in deliveryTypeData)
                    {
                        //update existing delivery type details
                        if (Convert.ToInt16(newDeliveryType.DeliveryTypeId) != command.DeliveryValue)
                        {
                            var deliveryValue = _eventDeliveryTypeDetailRepository.Get(newDeliveryType.Id);
                            deliveryValue.DeliveryTypeId = (DeliveryTypes)command.DeliveryValue;
                            _eventDeliveryTypeDetailRepository.Save(deliveryValue);
                        }
                    }
                }
                else // insert new deliveryType
                {
                    var deliveryType = new FIL.Contracts.DataModels.EventDeliveryTypeDetail
                    {
                        EventDetailId  = eventDetailData.Id,
                        DeliveryTypeId = (DeliveryTypes)command.DeliveryValue,
                        Notes          = "<p><strong>Delivery<br /></strong>Ticket packages are shipped to your preferred address (signature upon receival required), or are arranged for a secure pickup location at or near the circuit.</p>",
                        EndDate        = DateTime.UtcNow,
                        IsEnabled      = true,
                        CreatedUtc     = DateTime.UtcNow,
                        ModifiedBy     = command.userAltId,
                    };
                    _eventDeliveryTypeDetailRepository.Save(deliveryType);
                }
                var matchAttributeData = _matchAttributeRepository.GetByEventDetailId(eventDetail.id);
                if (matchAttributeData.Count() > 0)
                {
                    foreach (var oldMatchAttribute in matchAttributeData)
                    {
                        foreach (var newMatchAttribute in eventDetail.matches)
                        {
                            if (oldMatchAttribute.Id == newMatchAttribute.id)
                            {
                                var updatedMatchAttribute = _matchAttributeRepository.Get(newMatchAttribute.id);
                                updatedMatchAttribute.TeamA          = newMatchAttribute.teamA;
                                updatedMatchAttribute.TeamB          = newMatchAttribute.teamB;
                                updatedMatchAttribute.MatchNo        = newMatchAttribute.matchNo;
                                updatedMatchAttribute.MatchDay       = newMatchAttribute.matchDay;
                                updatedMatchAttribute.MatchStartTime = DateTime.Parse(newMatchAttribute.startDateTime);
                                _matchAttributeRepository.Save(updatedMatchAttribute);
                            }
                        }
                    }
                }
                else
                {
                    //check for not null
                    if (eventDetail.matches.Count > 0)
                    {
                        foreach (var match in eventDetail.matches)
                        {
                            //check for if team is exits if not insert new
                            var teamA = match.teamA != 0 ? _teamRepository.Get(match.teamA) :
                                        _teamRepository.Save(
                                new Team
                            {
                                Name        = match.teamAName,
                                AltId       = Guid.NewGuid(),
                                IsEnabled   = true,
                                Description = "",
                                CreatedUtc  = DateTime.UtcNow,
                                UpdatedUtc  = DateTime.UtcNow,
                                CreatedBy   = command.userAltId,
                                UpdatedBy   = command.userAltId
                            }
                                );

                            var teamB = match.teamB != 0 ? _teamRepository.Get(match.teamB) :
                                        _teamRepository.Save(
                                new Team
                            {
                                Name        = match.teamBName,
                                AltId       = Guid.NewGuid(),
                                IsEnabled   = true,
                                Description = "",
                                CreatedUtc  = DateTime.UtcNow,
                                UpdatedUtc  = DateTime.UtcNow,
                                CreatedBy   = command.userAltId,
                                UpdatedBy   = command.userAltId
                            }
                                );

                            var matchAttribute = new FIL.Contracts.DataModels.MatchAttribute
                            {
                                EventDetailId  = eventDetailData.Id,
                                TeamA          = teamA.Id,
                                TeamB          = teamB.Id,
                                MatchNo        = match.matchNo,
                                MatchDay       = match.matchDay,
                                IsEnabled      = true,
                                MatchStartTime = DateTime.Parse(match.startDateTime),
                                CreatedUtc     = DateTime.UtcNow,
                                CreatedBy      = command.userAltId,
                                ModifiedBy     = command.userAltId
                            };
                            _matchAttributeRepository.Save(matchAttribute);
                        }
                    }
                }

                var TicketDetailData = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.id);
                if (TicketDetailData.Count() > 0)
                {
                    foreach (var oldTicketCategory in TicketDetailData)
                    {
                        var newEventTicketDetail = eventDetail.ticketCategories.Where(s => s.id == oldTicketCategory.Id).FirstOrDefault();
                        if (newEventTicketDetail != null)
                        {
                            //update existing eventTicketDetail
                            var updatedEventTicketDetail = _eventTicketDetailRepository.Get(newEventTicketDetail.id);
                            updatedEventTicketDetail.TicketCategoryId = newEventTicketDetail.ticketCategoryId;
                            _eventTicketDetailRepository.Save(updatedEventTicketDetail);

                            //update event ticket attributes
                            var updatedTicketAttibutesData = _eventTicketAttributeRepository.GetByEventTicketDetailId(updatedEventTicketDetail.Id);
                            updatedTicketAttibutesData.AvailableTicketForSale = newEventTicketDetail.capacity;
                            updatedTicketAttibutesData.RemainingTicketForSale = newEventTicketDetail.capacity;
                            updatedTicketAttibutesData.Price           = newEventTicketDetail.price;
                            updatedTicketAttibutesData.LocalPrice      = newEventTicketDetail.price;
                            updatedTicketAttibutesData.CurrencyId      = newEventTicketDetail.currencyId;
                            updatedTicketAttibutesData.LocalCurrencyId = newEventTicketDetail.currencyId;
                            _eventTicketAttributeRepository.Save(updatedTicketAttibutesData);

                            //get exisiting ticket fee details
                            var oldticketFeeDetailData = _ticketFeeDetailRepository.GetAllByEventTicketAttributeId(updatedTicketAttibutesData.Id).ToList();

                            foreach (var feeType in command.FeeTypes)
                            {
                                if (feeType.id == 0)
                                {
                                    var ticketFeeDetailData = new FIL.Contracts.DataModels.TicketFeeDetail
                                    {
                                        EventTicketAttributeId = updatedTicketAttibutesData.Id,
                                        FeeId       = (Int16)feeType.feeId,
                                        DisplayName = feeType.displayName,
                                        ValueTypeId = (Int16)feeType.valueTypeId,
                                        Value       = feeType.value,
                                        IsEnabled   = true,
                                        CreatedUtc  = DateTime.UtcNow,
                                        CreatedBy   = command.userAltId
                                    };
                                    _ticketFeeDetailRepository.Save(ticketFeeDetailData);
                                }
                            }

                            if (oldticketFeeDetailData.Count() > 0)
                            {
                                foreach (var oldTicketFeeDetail in oldticketFeeDetailData)
                                {
                                    var newTicketFeeDetail = command.FeeTypes.Where(s => s.id == oldTicketFeeDetail.Id).FirstOrDefault();

                                    if (newTicketFeeDetail != null)
                                    {
                                        var updatedTicketFeeDetail = _ticketFeeDetailRepository.Get(oldTicketFeeDetail.Id);
                                        updatedTicketFeeDetail.FeeId       = Convert.ToInt16(newTicketFeeDetail.feeId);
                                        updatedTicketFeeDetail.ValueTypeId = Convert.ToInt16(newTicketFeeDetail.valueTypeId);
                                        updatedTicketFeeDetail.Value       = newTicketFeeDetail.value;
                                        _ticketFeeDetailRepository.Save(updatedTicketFeeDetail);
                                    }
                                    else
                                    {
                                        var updatedTicketFeeDetail = _ticketFeeDetailRepository.Get(oldTicketFeeDetail.Id);
                                        updatedTicketFeeDetail.IsEnabled = false;
                                        _ticketFeeDetailRepository.Save(updatedTicketFeeDetail);
                                    }
                                }
                            }
                        }
                        else
                        {
                            var updatedEventTicketDetail = _eventTicketDetailRepository.Get(oldTicketCategory.Id);
                            updatedEventTicketDetail.IsEnabled = false;
                            _eventTicketDetailRepository.Save(updatedEventTicketDetail);
                        }
                    }
                }

                if (eventDetail.ticketCategories.Count > 0)
                {
                    foreach (var eventTicketDetail in eventDetail.ticketCategories)
                    {
                        if (eventTicketDetail.id == 0) // insert new category
                        {
                            //check for if ticket category is exits if not insert new
                            var ticketCategory = eventTicketDetail.ticketCategoryId != 0 ? _ticketCategoryRepository.Get(eventTicketDetail.ticketCategoryId) :
                                                 _ticketCategoryRepository.Save(
                                new TicketCategory
                            {
                                Name       = eventTicketDetail.ticketCategoryName,
                                IsEnabled  = true,
                                CreatedUtc = DateTime.UtcNow,
                                UpdatedUtc = DateTime.UtcNow,
                                CreatedBy  = command.userAltId,
                                UpdatedBy  = command.userAltId
                            }
                                );
                            //insert new ticket detail data
                            var eventTicketDetailData = new FIL.Contracts.DataModels.EventTicketDetail
                            {
                                EventDetailId    = eventDetailData.Id,
                                TicketCategoryId = ticketCategory.Id,
                                IsEnabled        = true,
                                CreatedUtc       = DateTime.UtcNow,
                                CreatedBy        = command.userAltId,
                                ModifiedBy       = command.userAltId,
                                IsBOEnabled      = false
                            };
                            _eventTicketDetailRepository.Save(eventTicketDetailData);

                            //save event ticket attributes
                            var eventTicketAttibutesData = new FIL.Contracts.DataModels.EventTicketAttribute
                            {
                                EventTicketDetailId    = eventTicketDetailData.Id,
                                CurrencyId             = eventTicketDetail.currencyId,
                                TicketTypeId           = FIL.Contracts.Enums.TicketType.Adult,
                                ChannelId              = FIL.Contracts.Enums.Channels.Website,
                                AvailableTicketForSale = eventTicketDetail.capacity,
                                RemainingTicketForSale = eventTicketDetail.capacity,
                                Price                      = eventTicketDetail.price,
                                LocalPrice                 = eventTicketDetail.price,
                                CreatedUtc                 = DateTime.UtcNow,
                                CreatedBy                  = command.userAltId,
                                IsEnabled                  = true,
                                IsEMIApplicable            = false,
                                IsInternationalCardAllowed = false,
                                IsSeatSelection            = false,
                                ViewFromStand              = "",
                                TicketCategoryDescription  = "",
                                LocalCurrencyId            = eventTicketDetail.currencyId,
                                SalesStartDateTime         = DateTime.UtcNow,
                                SalesEndDatetime           = DateTime.UtcNow,
                            };
                            _eventTicketAttributeRepository.Save(eventTicketAttibutesData);

                            if (command.FeeTypes.Count > 0)
                            {
                                foreach (var feeType in command.FeeTypes)
                                {
                                    //save ticket fee details
                                    var ticketFeeDetailData = new FIL.Contracts.DataModels.TicketFeeDetail
                                    {
                                        EventTicketAttributeId = eventTicketAttibutesData.Id,
                                        FeeId       = (Int16)feeType.feeId,
                                        DisplayName = feeType.displayName,
                                        ValueTypeId = (Int16)feeType.valueTypeId,
                                        Value       = feeType.value,
                                        IsEnabled   = true,
                                        CreatedUtc  = DateTime.UtcNow,
                                        CreatedBy   = command.userAltId
                                    };
                                    _ticketFeeDetailRepository.Save(ticketFeeDetailData);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #8
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);
            }
        }
        protected FIL.Contracts.DataModels.EventDetail SaveEventDetail(EventScheduleCommand command, Event currentEvent)
        {
            if (command.EventScheduleModel.EventFrequencyType == Contracts.Enums.EventFrequencyType.Recurring)
            {
                var eventScheduleDetail = _getScheduleDetailProvider.GetScheduleDetails(currentEvent.Id, new DateTime(), new DateTime(), true).FirstOrDefault();
                if (eventScheduleDetail != null)
                {
                    command.EventScheduleModel.StartDateTime = eventScheduleDetail.StartDateTime;
                    command.EventScheduleModel.EndDateTime   = eventScheduleDetail.EndDateTime;
                }
                else
                {
                    command.EventScheduleModel.StartDateTime = DateTime.UtcNow;
                    command.EventScheduleModel.EndDateTime   = DateTime.UtcNow;
                }
            }
            EventDetail eventDetail = new EventDetail();

            eventDetail                    = command.EventScheduleModel.EventDetailId != 0 ? _eventDetailRepository.Get(command.EventScheduleModel.EventDetailId) : eventDetail;
            eventDetail.AltId              = command.EventScheduleModel.EventDetailId != 0 ? eventDetail.AltId : Guid.NewGuid();
            eventDetail.Id                 = command.EventScheduleModel.EventDetailId != 0 ? eventDetail.Id : 0;
            eventDetail.EventId            = command.EventScheduleModel.EventId;
            eventDetail.Description        = "NA";
            eventDetail.IsEnabled          = true;
            eventDetail.Name               = currentEvent.Name;
            eventDetail.VenueId            = command.EventScheduleModel.VenueId;
            eventDetail.IsEnabled          = command.EventScheduleModel.IsEnabled;
            eventDetail.StartDateTime      = command.EventScheduleModel.StartDateTime;
            eventDetail.EndDateTime        = command.EventScheduleModel.EndDateTime;
            eventDetail.GroupId            = 1;
            eventDetail.EventFrequencyType = command.EventScheduleModel.EventFrequencyType;
            eventDetail.CreatedUtc         = eventDetail.Id != 0 ? eventDetail.CreatedUtc : DateTime.UtcNow;
            eventDetail.UpdatedUtc         = eventDetail.Id != 0 ? DateTime.UtcNow : eventDetail.CreatedUtc;
            eventDetail.CreatedBy          = eventDetail.Id != 0 ? eventDetail.CreatedBy : command.ModifiedBy;
            eventDetail.UpdatedBy          = command.ModifiedBy;
            eventDetail.ModifiedBy         = command.ModifiedBy;
            return(_eventDetailRepository.Save(eventDetail));
        }
Пример #10
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);
            }
        }
Пример #11
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
                {
                });
            }
        }
Пример #12
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);
        }