示例#1
0
        public TransactionInfoQueryResult Handle(TransactionInfoQuery query)
        {
            var             transaction            = AutoMapper.Mapper.Map <Contracts.Models.Transaction>(_transactionRepository.GetByTransactionAltId(query.TransactionAltId));
            TransactionType transactionType        = TransactionType.Regular;
            var             transactionModel       = AutoMapper.Mapper.Map <FIL.Contracts.Models.Transaction>(transaction);
            var             transactionDetails     = _transactionDetailsRepository.GetByTransactionId(transactionModel.Id);
            var             transactionDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TransactionDetail> >(transactionDetails);

            if (transactionDetails.FirstOrDefault().TransactionType == TransactionType.QRCode)
            {
                transactionType = TransactionType.QRCode;
            }
            var eventTicketAttributeDetails = AutoMapper.Mapper.Map <List <Contracts.Models.EventTicketAttribute> >(_eventTicketAttributeRepository.GetByEventTicketAttributeIds(transactionDetails.Select(s => s.EventTicketAttributeId)));

            var eventTicketDetails = _eventTicketDetailRepository.GetByEventTicketDetailIds(eventTicketAttributeDetails.Select(s => s.EventTicketDetailId));

            var eventDetails = _eventDetailRepository.GetByEventDetailIds(eventTicketDetails.Select(s => s.EventDetailId).Distinct());

            IEnumerable <FIL.Contracts.DataModels.Event> events = new List <FIL.Contracts.DataModels.Event>();

            events = _eventRepository.GetByAllTypeEventIds(eventDetails.Select(s => s.EventId).Distinct());

            var currency = _currencyType.Get(transaction.CurrencyId);

            return(new TransactionInfoQueryResult
            {
                Transaction = transaction,
                CurrencyName = currency.Code,
                TransactionType = transactionType,
                Events = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.Event> >(events),
                EventTicketAttributes = eventTicketAttributeDetails,
                TransactionDetails = transactionDetailModel
            });
        }
示例#2
0
 protected override async Task <ICommandResult> Handle(CreateTicketCommand command)
 {
     try
     {
         List <FIL.Contracts.Models.CreateEventV1.TicketModel> ticketModelList = new List <FIL.Contracts.Models.CreateEventV1.TicketModel>();
         var eventDetail = _eventDetailRepository.GetByEventId(command.EventId);
         var etdTicketCategoryMapping = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(command.Tickets.Select(s => s.ETDId).ToList());
         var eventTicketDetails       = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.Id).ToList();
         var eventTicketAttributes    = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => s.Id).ToList()).ToList();
         var currency = _currencyTypeRepository.Get(command.Tickets.FirstOrDefault().CurrencyId);
         foreach (var currentEta in eventTicketAttributes)
         {
             currentEta.CurrencyId = currency.Id;
             _eventTicketAttributeRepository.Save(currentEta);
         }
         eventTicketDetails    = eventTicketDetails.Where(s => command.Tickets.Any(p => p.ETDId == s.Id)).ToList();
         eventTicketAttributes = eventTicketAttributes.Where(s => command.Tickets.Any(p => p.ETDId == s.EventTicketDetailId)).ToList();
         foreach (var ticketModel in command.Tickets)
         {
             ticketModel.CurrencyCode     = currency.Code;
             ticketModel.TicketCategoryId = SaveTicketCategory(command, ticketModel).Id;
             var etd = SaveEventTicketDetails(command, ticketModel, eventDetail, eventTicketDetails);
             ticketModel.ETDId       = etd.Id;
             ticketModel.TicketAltId = etd.AltId;
             var currentEventTicketAttribute = SaveEventTicketAttribute(command, ticketModel, eventTicketAttributes);
             SaveEventticketDetailTicketCategoryTypeMappings(command, ticketModel);
             SaveTicketDiscount(command, currentEventTicketAttribute.Id, eventDetail.Name);
             ticketModelList.Add(ticketModel);
         }
         SaveEventStripeMappings(command.EventId, command.Tickets.FirstOrDefault().CurrencyId);
         SaveDonationDetail(command);
         var eventStepDetail = _stepProvider.SaveEventStepDetails(command.EventId, command.CurrentStep, true, command.ModifiedBy);
         return(new CreateTicketCommandResult
         {
             Tickets = ticketModelList,
             CompletedStep = eventStepDetail.CompletedStep,
             CurrentStep = eventStepDetail.CurrentStep,
             Success = true
         });
     }
     catch (Exception e)
     {
         _logger.Log(LogCategory.Error, e);
         return(new CreateTicketCommandResult {
         });
     }
 }
示例#3
0
 public FIL.Contracts.DataModels.CurrencyType GetEventCurrency(FIL.Contracts.DataModels.Event @event)
 {
     try
     {
         var eventDetails         = _eventDetailRepository.GetByEventId(@event.Id);
         var eventTicketDetail    = _eventTicketDetailRepository.GetByEventDetailId(eventDetails.Id).FirstOrDefault();
         var eventTicketAttribute = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id);
         var currency             = _currencyTypeRepository.Get(eventTicketAttribute.CurrencyId);
         return(currency);
     }
     catch (Exception e)
     {
         _logger.Log(FIL.Logging.Enums.LogCategory.Error, e);
         return(new FIL.Contracts.DataModels.CurrencyType {
         });
     }
 }
        public SubEventTicketCategoryQueryResult Handle(SubEventTicketCategoryQuery query)
        {
            var eventDetailModelDataModel = _eventDetailRepository.GetById(query.EventDetailId);
            var eventDetailModel          = AutoMapper.Mapper.Map <Contracts.Models.EventDetail>(eventDetailModelDataModel);

            var venueDetailDataModel = _venueRepository.Get(eventDetailModelDataModel.VenueId);
            var venueDetailModel     = AutoMapper.Mapper.Map <Contracts.Models.Venue>(venueDetailDataModel);

            var cityDetailDataModel = _cityRepository.Get(venueDetailDataModel.CityId);
            var cityModel           = AutoMapper.Mapper.Map <Contracts.Models.City>(cityDetailDataModel);

            var eventTicketDetailDataModel = _eventTicketDetailRepository.GetByEventDetailId(eventDetailModelDataModel.Id);
            var eventTicketDetailModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketDetail> >(eventTicketDetailDataModel);

            var ticketCategoryIdList    = eventTicketDetailModel.Select(s => s.TicketCategoryId);
            var ticketCategoryDataModel = _ticketCategoryRepository.GetByEventDetailIds(ticketCategoryIdList);
            var ticketCategoryModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.TicketCategory> >(ticketCategoryDataModel);

            var eventTicketDetailIdList      = eventTicketDetailModel.Select(s => s.Id);
            var eventTicketDetailIdDataModel = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetailIdList);
            var eventTicketAttributeModel    = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketAttribute> >(eventTicketDetailIdDataModel);

            var currencyList  = eventTicketAttributeModel.Select(s => s.CurrencyId).Distinct().FirstOrDefault();
            var currencyModel = AutoMapper.Mapper.Map <Contracts.Models.CurrencyType>(_currencyTypeRepository.Get(currencyList));

            return(new SubEventTicketCategoryQueryResult
            {
                EventDetail = eventDetailModel,
                EventTicketAttribute = eventTicketAttributeModel,
                Venue = venueDetailModel,
                City = cityModel,
                EventTicketDetail = eventTicketDetailModel,
                TicketCategory = ticketCategoryModel,
                CurrencyType = currencyModel
            });
        }
        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);
            }
        }
示例#6
0
        protected override async Task <ICommandResult> Handle(PaymentCommand query)
        {
            var  transaction = _transactionRepository.Get(query.TransactionId);
            var  currency    = _currencyTypeRepository.Get(transaction.CurrencyId);
            User user        = _userRepository.GetByEmail(transaction.EmailId);

            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(query.PaymentCard.CardNumber, user.Id);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = user.Id,
                    AltId       = new Guid(),
                    NameOnCard  = query.PaymentCard.NameOnCard ?? string.Empty,
                    CardNumber  = query.PaymentCard.CardNumber ?? string.Empty,
                    ExpiryMonth = query.PaymentCard.ExpiryMonth,
                    ExpiryYear  = query.PaymentCard.ExpiryYear,
                    CardTypeId  = query.PaymentCard.CardType
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            try
            {
                if (query.BillingAddress != null)
                {
                    if (query.BillingAddress.Zipcode == null)
                    {
                        query.BillingAddress.Zipcode = "110016";
                    }

                    var zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    if (zipcode == null)
                    {
                        var city    = _cityRepository.GetByName(query.BillingAddress.City);
                        var zipCode = new Zipcode
                        {
                            AltId      = Guid.NewGuid(),
                            Postalcode = query.BillingAddress.Zipcode.ToString(),
                            CityId     = city != null ? city.Id : 0,
                            IsEnabled  = true
                        };

                        _zipcodeRepository.Save(zipCode);

                        zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    }
                    if (user != null && zipcode != null)
                    {
                        var addressDetail = new UserAddressDetail
                        {
                            UserId        = user.Id,
                            AltId         = Guid.NewGuid(),
                            FirstName     = user.FirstName,
                            LastName      = user.LastName,
                            PhoneCode     = user.PhoneCode,
                            PhoneNumber   = user.PhoneNumber,
                            AddressLine1  = query.BillingAddress.Address,
                            Zipcode       = zipcode.Id,
                            AddressTypeId = AddressTypes.Billing,
                            IsEnabled     = true
                        };

                        _userAddressDetailRepository.Save(addressDetail);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            if (query.PaymentGateway != null)
            {
                List <FIL.Contracts.DataModels.TransactionDetail> transactionDetails = _transactionDetailRepository.GetByTransactionId(transaction.Id).ToList();
                if (transactionDetails.Any())
                {
                    List <FIL.Contracts.DataModels.TransactionSeatDetail> transactionSeatDetails = _transactionSeatDetailRepository.GetByTransactionDetailIds(transactionDetails.Select(s => s.Id)).ToList();
                    if (transactionSeatDetails != null)
                    {
                        var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByMatchSeatTicketDetailIds(transactionSeatDetails.Select(s => s.MatchSeatTicketDetailId)).ToList();

                        if (matchSeatTicketDetail != null && matchSeatTicketDetail.Any())
                        {
                            return(new PaymentCommandResult
                            {
                                TransactionAltId = transaction.AltId,
                                PaymentResponse = new PaymentResponse
                                {
                                    Success = false,
                                    PaymentGatewayError = PaymentGatewayError.Unknown
                                }
                            });
                        }
                    }
                }
            }

            if (query.PaymentGateway == PaymentGateway.Stripe)
            {
                bool isIntentConfirm = false;
                if (query.PaymentCard.NameOnCard != null)
                {
                    isIntentConfirm = query.PaymentCard.NameOnCard.Equals("intent", StringComparison.InvariantCultureIgnoreCase);
                }
                var paymentResponse = await _stripeCharger.Charge(new StripeCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    Token            = query.Token,
                    ChannelId        = query.ChannelId,
                    IsIntentConfirm  = isIntentConfirm
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = paymentResponse
                });
            }

            if (query.PaymentGateway != null && query.PaymentGateway == PaymentGateway.NabTransact)
            {
                var paymentHtmlPostResponse = await _nabTransactCharger.Charge(new NabTransactCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName    = user.FirstName,
                        LastName     = user.LastName,
                        PhoneCode    = user.PhoneCode,
                        PhoneNumber  = user.PhoneNumber,
                        Email        = user.Email,
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "3032",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    PaymentOption = PaymentOptions.CreditCard,
                    User          = new FIL.Contracts.Models.User
                    {
                        Email = user.Email
                    },
                    //IPAddress = ipDetail.IPAddress
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            if (PaymentOptions.CreditCard == query.PaymentOption || PaymentOptions.DebitCard == query.PaymentOption)
            {
                IHdfcEnrollmentResponse hdfcEnrollmentResponse = _hdfcChargerResolver.HdfcEnrollmentVerification(new HdfcCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    }
                });

                if (hdfcEnrollmentResponse.PaymentGatewayError == PaymentGatewayError.None)
                {
                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "ENROLLED")
                    {
                        var paymentHtmlPostResponse = await _hdfcPaymentHtmlPostCharger.Charge(hdfcEnrollmentResponse.HdfcEnrolledCharge);

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentHtmlPostResponse = paymentHtmlPostResponse
                        });
                    }

                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "NOT ENROLLED")
                    {
                        var paymentResponse = await _hdfcCharger.Charge(new HdfcCharge
                        {
                            TransactionId    = transaction.Id,
                            Currency         = currency.Code,
                            Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                            UserCardDetailId = userCardDetail.Id,
                            PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                            {
                                CardNumber  = query.PaymentCard.CardNumber,
                                NameOnCard  = query.PaymentCard.NameOnCard,
                                Cvv         = query.PaymentCard.Cvv,
                                ExpiryMonth = query.PaymentCard.ExpiryMonth,
                                ExpiryYear  = query.PaymentCard.ExpiryYear,
                                CardType    = query.PaymentCard.CardType
                            }
                        });

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentResponse = paymentResponse
                        });
                    }
                }

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = new PaymentResponse
                    {
                        Success = false,
                        PaymentGatewayError = hdfcEnrollmentResponse.PaymentGatewayError
                    }
                });
            }

            if (PaymentOptions.NetBanking == query.PaymentOption || PaymentOptions.CashCard == query.PaymentOption)
            {
                var paymentHtmlPostResponse = await _ccavenuePaymentHtmlPostCharger.Charge(new CcavenueCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    PaymentOption  = (PaymentOptions)query.PaymentOption,
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName   = !string.IsNullOrWhiteSpace(transaction.FirstName) ? transaction.FirstName : "Zoonga",
                        LastName    = !string.IsNullOrWhiteSpace(transaction.LastName) ? transaction.LastName : "Zoonga",
                        PhoneCode   = !string.IsNullOrWhiteSpace(transaction.PhoneCode) ? transaction.PhoneCode : "91",
                        PhoneNumber = !string.IsNullOrWhiteSpace(transaction.PhoneNumber) ? transaction.PhoneNumber : "9899704772",
                        Email       = !string.IsNullOrWhiteSpace(transaction.EmailId) ? transaction.EmailId : "*****@*****.**",
                        //FirstName = "Gaurav",
                        //LastName = "Bhardwaj",
                        //PhoneCode = "91",
                        //PhoneNumber = "9899704772",
                        //Email = "*****@*****.**",
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "110016",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    BankAltId = query.BankAltId,
                    CardAltId = query.CardAltId,
                    ChannelId = query.ChannelId,
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            return(new PaymentCommandResult
            {
                TransactionAltId = transaction.AltId,
                PaymentResponse = new PaymentResponse
                {
                    Success = false,
                    PaymentGatewayError = PaymentGatewayError.Unknown
                }
            });
        }
示例#7
0
        protected override Task <ICommandResult> Handle(ApplyDiscountCommand command)
        {
            var transaction = _transactionRepository.Get(command.TransactionId);

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

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

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

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

            ApplyDiscountCommandResult applyDiscountCommandResult = new ApplyDiscountCommandResult();

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

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

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

            return(Task.FromResult <ICommandResult>(applyDiscountCommandResult));
        }
示例#8
0
        public TicketCategoryQueryResult Handle(TicketCategoryQuery query)
        {
            try
            {
                var eventDataModel = _eventRepository.GetByAltId(query.EventAltId);
                var eventModel     = AutoMapper.Mapper.Map <Contracts.Models.Event>(eventDataModel);
                if (eventModel != null)
                {
                    var ASIMonumentMapping = _aSIMonumentEventTableMappingRepository.GetByEventId(eventModel.Id);
                    var ASIMonument        = new Contracts.Models.ASI.Item();
                    if (ASIMonumentMapping != null)
                    {
                        ASIMonument = Mapper.Map <Contracts.Models.ASI.Item>(_aSIMonumentRepository.Get(ASIMonumentMapping.ASIMonumentId));
                    }
                    var eventCategoryMappings     = _eventCategoryMappingRepository.GetByEventId(eventModel.Id).FirstOrDefault();
                    var eventDetailModelDataModel = _eventDetailRepository.GetSubEventByEventId(eventModel.Id);
                    var eventDetailModel          = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventDetail> >(eventDetailModelDataModel);
                    List <FIL.Contracts.Models.ASI.EventTimeSlotMapping> eventTimeSlotMappings = new List <Contracts.Models.ASI.EventTimeSlotMapping>();
                    List <EventVenueMappingTime>       eventVenueMappingTimeModel = new List <EventVenueMappingTime>();
                    FIL.Contracts.Models.EventCategory subCategory = new FIL.Contracts.Models.EventCategory();
                    FIL.Contracts.Models.EventCategory category    = new FIL.Contracts.Models.EventCategory();
                    try
                    {
                        var eventTimeSlot = _eventTimeSlotMappingRepository.GetByEventId(eventModel.Id);
                        eventTimeSlotMappings = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.ASI.EventTimeSlotMapping> >(eventTimeSlot).ToList();
                    }
                    catch (Exception e)
                    {
                    }
                    if (eventCategoryMappings != null)
                    {
                        var subCategoryDataModel = _eventCategoryRepository.Get(eventCategoryMappings.EventCategoryId);
                        if (subCategory != null)
                        {
                            subCategory = AutoMapper.Mapper.Map <Contracts.Models.EventCategory>(subCategoryDataModel);
                            var categoryDataModel = _eventCategoryRepository.Get(subCategory.EventCategoryId);
                            category = AutoMapper.Mapper.Map <Contracts.Models.EventCategory>(categoryDataModel);
                        }
                    }
                    var ticketCategoryType    = _ticketCategoryTypesRepository.GetAll();
                    var ticketCategorySubType = _ticketCategorySubTypesRepository.GetAll();

                    var placeHolidyDatesDataModel = _placeHolidayDatesRepository.GetAllByEventId(eventDataModel.Id);
                    var placeHolidyDatesModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.PlaceHolidayDate> >(placeHolidyDatesDataModel);

                    var placeWeekOffDataModel = _placeWeekOffRepository.GetAllByEventId(eventDataModel.Id);
                    var placeWeekOffModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.PlaceWeekOff> >(placeWeekOffDataModel);

                    var placeDocumentDataModel = _placeCustomerDocumentTypeMappingRepository.GetAllByEventId(eventDataModel.Id);
                    var placeDocumentModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.PlaceCustomerDocumentTypeMapping> >(placeDocumentDataModel);

                    var placeOpenDays      = _placeWeekOpenDaysRepository.GetByEventId(eventDataModel.Id);
                    var placeOpenDaysModel = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.PlaceWeekOpenDays> >(placeOpenDays);

                    var CustomerDocumentTypeDataModel = _customerDocumentTypeRepository.GetAll();
                    var CustomerDocumentTypeModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.CustomerDocumentType> >(CustomerDocumentTypeDataModel);

                    if (eventDetailModelDataModel != null && eventDetailModelDataModel.Any())
                    {
                        var eventDeliveryTypeDetailDataModel = _eventDeliveryTypeDetail.GetByEventDetailId(eventDetailModelDataModel.ElementAt(0).Id);
                        var eventDeliveryTypeDetailModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventDeliveryTypeDetail> >(eventDeliveryTypeDetailDataModel);

                        var RASVTicketTypeMappingsDataModel = _rasvTicketTypeMappingRepository.GetByEventDetailIds(eventDetailModelDataModel.Select(ed => ed.Id)).Where(sed => sed.IsEnabled == true);
                        var RASVTicketTypeMappingsModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.RASVTicketTypeMapping> >(RASVTicketTypeMappingsDataModel);

                        var venueDetailDataModel = _venueRepository.GetByVenueIds(eventDetailModel.Select(s => s.VenueId));
                        var venueDetailModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.Venue> >(venueDetailDataModel);

                        //Multiple Venue option for MOVE AROUND category.
                        var eventVenueMappingDataModel = _eventVenueMappingRepository.GetOneByEventId(eventModel.Id);
                        var eventVenueMappingModel     = Mapper.Map <EventVenueMapping>(eventVenueMappingDataModel);
                        if (eventVenueMappingModel != null)
                        {
                            var eventVenueMappingTimeDataModel = _eventVenueMappingTimeRepository.GetAllByEventVenueMappingId(eventVenueMappingModel.Id);
                            eventVenueMappingTimeModel = Mapper.Map <IEnumerable <EventVenueMappingTime> >(eventVenueMappingTimeDataModel).ToList();
                        }

                        var CityList            = venueDetailDataModel.Select(s => s.CityId);
                        var cityDetailDataModel = _cityRepository.GetByCityIds(CityList);
                        var cityModel           = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.City> >(cityDetailDataModel);

                        var eventTicketDetailList      = eventDetailModelDataModel.Select(s => s.Id);
                        var eventTicketDetailDataModel = _eventTicketDetailRepository.GetByEventDetailIds(eventTicketDetailList);
                        var eventTicketDetailModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketDetail> >(eventTicketDetailDataModel);

                        // For Getting Pone venue Images
                        var pOneImageEventDetailMapping = new List <Contracts.Models.POne.POneImageEventDetailMapping>();
                        if (eventModel.EventSourceId == EventSource.POne)
                        {
                            var pOneEventDetailMappings = _pOneEventDetailMappingRepository.GetByEventDetailIds(eventTicketDetailModel.Select(s => s.EventDetailId).Distinct().ToList());
                            var allTicketCategories     = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetailModel.Select(s => s.TicketCategoryId).Distinct().ToList());
                            var allPoneETD = _pOneEventTicketDetailRepository.GetByManyPOneEventDetail(pOneEventDetailMappings.Select(s => s.POneEventDetailId).Distinct().ToList());
                            foreach (var item in eventTicketDetailModel)
                            {
                                var pOneEventDetailMappingData = pOneEventDetailMappings.Where(s => s.ZoongaEventDetailId == item.EventDetailId).FirstOrDefault();
                                var tc   = allTicketCategories.Where(s => s.Id == item.TicketCategoryId).FirstOrDefault();
                                var p1tc = _pOneTicketCategoryRepository.GetByName(tc.Name);
                                if (pOneEventDetailMappingData != null && p1tc != null)
                                {
                                    var p1etd = allPoneETD.Where(s => (s.POneEventDetailId == pOneEventDetailMappingData.POneEventDetailId && s.POneTicketCategoryId == p1tc.POneId)).FirstOrDefault();
                                    if (p1etd != null)
                                    {
                                        pOneImageEventDetailMapping.Add(new Contracts.Models.POne.POneImageEventDetailMapping
                                        {
                                            EventTicketDetailId = item.Id,
                                            ImageUrl            = p1etd.ImageUrl
                                        });
                                    }
                                }
                            }
                        }

                        var eventTicketDetailTicketCategoryMappings      = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(eventTicketDetailModel.Select(s => s.Id).ToList());
                        var eventTicketDetailTicketCategoryMappingsModel = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketDetailTicketCategoryTypeMapping> >(eventTicketDetailTicketCategoryMappings).ToList();

                        var matchAttribute = _matchAttributeRepository.GetByEventDetailIds(eventDetailModelDataModel.Select(ed => ed.Id).Distinct());
                        var team           = _teamRepository.GetAll();
                        var data           = _calendarProvider.GetCalendarData(eventModel.Id);
                        if (eventTicketDetailModel != null)
                        {
                            var ticketCategoryIdList    = eventTicketDetailModel.Select(s => s.TicketCategoryId);
                            var ticketCategoryDataModel = _ticketCategoryRepository.GetByEventDetailIds(ticketCategoryIdList);
                            var ticketCategoryModel     = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.TicketCategory> >(ticketCategoryDataModel);

                            var eventTicketDetailIdList      = eventTicketDetailModel.Select(s => s.Id);
                            var eventTicketDetailIdDataModel = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetailIdList);
                            var eventTicketAttributeModel    = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketAttribute> >(eventTicketDetailIdDataModel);

                            var eventTicketAttributeIdList = eventTicketAttributeModel.Select(s => s.Id);
                            var ticketFeeDetailIdDataModel = _ticketFeeDetail.GetByEventTicketAttributeIds(eventTicketAttributeIdList);
                            var ticketFeeDetailModel       = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.TicketFeeDetail> >(ticketFeeDetailIdDataModel);

                            var currencyList  = eventTicketAttributeModel.Select(s => s.CurrencyId).Distinct().FirstOrDefault();
                            var currencyModel = AutoMapper.Mapper.Map <Contracts.Models.CurrencyType>(_currencyTypeRepository.Get(currencyList));

                            var days      = _daysRepository.GetAll();
                            var daysModel = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.Days> >(days);

                            var CountryRegionalOrganisation = _countryRegionalOrganisationMappingRepository.GetAll();

                            var eventAttribute = _eventAttributeRepository.GetByEventDetailIds(eventDetailModel.Select(s => (long)s.Id).ToList());

                            var           Country             = _countryRepository.GetAll();
                            var           Countrymodel        = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.Country> >(Country);
                            List <string> reginalOrganisation = new List <string>();
                            reginalOrganisation.AddRange(Enum.GetNames(typeof(FIL.Contracts.Enums.RegionalOrganisation)));

                            // For Tiqet's gettting Checkout Details
                            TiqetProductCheckoutDetail
                                tiqetCheckoutDetailsModel = new TiqetProductCheckoutDetail();
                            List <ValidWithVariantModel> validWithVariantList = new List <ValidWithVariantModel>();
                            if (eventModel.EventSourceId == EventSource.Tiqets)
                            {
                                var tiqetEventDetailMapping = _tiqetEventDetailMappingRepository.GetByEventDetailId(eventDetailModel.ElementAt(0).Id);
                                var tiqetCheckoutDetails    = _tiqetProductCheckoutDetailRepository.GetByProductId(tiqetEventDetailMapping.ProductId);
                                tiqetCheckoutDetailsModel = Mapper.Map <TiqetProductCheckoutDetail>(tiqetCheckoutDetails);
                                // for checking valid with tiqetVariant details
                                var tiqetVariantDetails = _tiqetVariantDetailRepository.GetAllByProductId(tiqetCheckoutDetailsModel.ProductId);

                                List <long> eventTicketDetailIds = new List <long>();
                                foreach (var currentVariantDetail in tiqetVariantDetails)
                                {
                                    if (currentVariantDetail.ValidWithVariantIds != null && currentVariantDetail.ValidWithVariantIds != "")
                                    {
                                        ValidWithVariantModel validWithVariantModel = new ValidWithVariantModel();
                                        var validWithVariantIds = currentVariantDetail.ValidWithVariantIds.Split(",");
                                        foreach (var currentValidvariantId in validWithVariantIds)
                                        {
                                            var currentValidVariantDetail = tiqetVariantDetails.Where(s => s.VariantId == Convert.ToInt64(currentValidvariantId)).FirstOrDefault();
                                            if (currentValidVariantDetail != null)
                                            {
                                                var eventTicketDetailMapping = _tiqetEventTicketDetailMappingRepository.GetByTiqetVariantId(currentValidVariantDetail.Id);
                                                eventTicketDetailIds.Add(eventTicketDetailMapping.EventTicketDetailId);
                                            }
                                        }
                                        var currentEventTicketDetailMapping = _tiqetEventTicketDetailMappingRepository.GetByTiqetVariantId(currentVariantDetail.Id);
                                        validWithVariantModel.EventTicketDetailId          = currentEventTicketDetailMapping.EventTicketDetailId;
                                        validWithVariantModel.ValidWithEventTicketDetailId = eventTicketDetailIds;
                                        validWithVariantList.Add(validWithVariantModel);
                                    }
                                }
                            }
                            // Check for Hoho Places if any
                            FIL.Contracts.DataModels.CitySightSeeingTicketDetail citySightSeeingTicketDetail = new FIL.Contracts.DataModels.CitySightSeeingTicketDetail();
                            var citySightSeeingEventDetailMapping = _citySightSeeingEventDetailMappingRepository.GetByEventDetailId(eventDetailModel.ElementAt(0).Id);
                            if (citySightSeeingEventDetailMapping != null)
                            {
                                var citySightSeeingTickets = _citySightSeeingTicketRepository.Get(citySightSeeingEventDetailMapping.CitySightSeeingTicketId);
                                citySightSeeingTicketDetail = _citySightSeeingTicketDetailRepository.GetByTicketId(citySightSeeingTickets.TicketId);
                            }
                            //Get Host Details for FIL Online Events
                            var eventHostMappingList = new List <FIL.Contracts.DataModels.EventHostMapping>();
                            var formattedDateString  = "";
                            if (eventDataModel.MasterEventTypeId == MasterEventType.Online)
                            {
                                eventHostMappingList = _eventHostMappingRepository.GetAllByEventId(eventDataModel.Id).ToList();
                                var formattedDateTime = _localTimeZoneConvertProvider.ConvertToLocal(eventDetailModel.FirstOrDefault().StartDateTime, eventAttribute.FirstOrDefault().TimeZone);
                                formattedDateString = formattedDateTime.DayOfWeek + ", " + formattedDateTime.ToString(@"MMM dd, yyyy, hh:mm tt", new CultureInfo("en-US"));
                            }
                            //Get Recurrance Schedule
                            List <FIL.Contracts.Models.CreateEventV1.EventRecurranceScheduleModel> recurranceScheduleModels = new List <Contracts.Models.CreateEventV1.EventRecurranceScheduleModel>();
                            if (eventDetailModel.FirstOrDefault().EventFrequencyType == EventFrequencyType.Recurring)
                            {
                                recurranceScheduleModels = _getScheduleDetailProvider.GetScheduleDetails(eventDataModel.Id, DateTime.UtcNow, DateTime.UtcNow, false, true).Where(s => s.EndDateTime > DateTime.UtcNow).ToList();
                            }
                            try
                            {
                                return(new TicketCategoryQueryResult
                                {
                                    Event = eventModel,
                                    EventDetail = eventDetailModel,
                                    EventTicketAttribute = eventTicketAttributeModel,
                                    TicketFeeDetail = ticketFeeDetailModel,
                                    Venue = venueDetailModel,
                                    City = cityModel,
                                    EventTicketDetail = eventTicketDetailModel,
                                    TicketCategory = ticketCategoryModel,
                                    CurrencyType = currencyModel,
                                    RASVTicketTypeMappings = RASVTicketTypeMappingsModel,
                                    EventDeliveryTypeDetails = eventDeliveryTypeDetailModel,
                                    EventCategory = eventModel.EventCategoryId,
                                    MatchAttribute = Mapper.Map <IEnumerable <MatchAttribute> >(matchAttribute),
                                    Team = Mapper.Map <IEnumerable <Team> >(team),
                                    PlaceCustomerDocumentTypeMappings = placeDocumentModel,
                                    PlaceHolidayDates = placeHolidyDatesModel,
                                    PlaceWeekOffs = placeWeekOffModel,
                                    CustomerDocumentTypes = CustomerDocumentTypeModel,
                                    TicketCategorySubTypes = ticketCategorySubType.ToList(),
                                    TicketCategoryTypes = ticketCategoryType.ToList(),
                                    EventTicketDetailTicketCategoryTypeMappings = eventTicketDetailTicketCategoryMappingsModel,
                                    EventCategoryMappings = eventCategoryMappings,
                                    RegularTimeModel = data.RegularTimeModel,
                                    SeasonTimeModel = data.SeasonTimeModel,
                                    SpecialDayModel = data.SpecialDayModel,
                                    EventVenueMappings = eventVenueMappingModel,
                                    EventVenueMappingTimes = eventVenueMappingTimeModel,
                                    EventTimeSlotMappings = eventTimeSlotMappings,
                                    PlaceWeekOpenDays = placeOpenDaysModel,
                                    Days = daysModel,
                                    CountryRegionalOrganisationMappings = CountryRegionalOrganisation.ToList(),
                                    Countries = Countrymodel,
                                    Category = category,
                                    SubCategory = subCategory,
                                    RegionalOrganisation = reginalOrganisation,
                                    TiqetsCheckoutDetails = tiqetCheckoutDetailsModel,
                                    ValidWithVariantModel = validWithVariantList,
                                    CitySightSeeingTicketDetail = Mapper.Map <FIL.Contracts.Models.CitySightSeeing.CitySightSeeingTicketDetail>(citySightSeeingTicketDetail),
                                    POneImageEventDetailMapping = pOneImageEventDetailMapping,
                                    EventHostMapping = eventHostMappingList,
                                    EventAttributes = eventAttribute.ToList(),
                                    eventRecurranceScheduleModels = recurranceScheduleModels,
                                    ASIMonument = ASIMonument,
                                    FormattedDateString = formattedDateString
                                });
                            }
                            catch (Exception e)
                            {
                                return(new TicketCategoryQueryResult
                                {
                                });
                            }
                        }
                        else
                        {
                            return(new TicketCategoryQueryResult
                            {
                                Event = eventModel,
                                EventDetail = eventDetailModel,
                                EventTicketAttribute = null,
                                TicketFeeDetail = null,
                                Venue = venueDetailModel,
                                City = cityModel,
                                EventTicketDetail = eventTicketDetailModel,
                                TicketCategory = null,
                                CurrencyType = null,
                                RASVTicketTypeMappings = RASVTicketTypeMappingsModel,
                                EventDeliveryTypeDetails = eventDeliveryTypeDetailModel,
                                EventCategory = eventModel.EventCategoryId,
                                MatchAttribute = null,
                                Team = null,
                                CitySightSeeingTicketDetail = null
                            });
                        }
                    }
                    else
                    {
                        return(new TicketCategoryQueryResult {
                        });
                    }
                }
                else
                {
                    return(new TicketCategoryQueryResult {
                    });
                }
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
                return(new TicketCategoryQueryResult {
                });
            }
        }
 protected override async Task <ICommandResult> Handle(StripeConnectAccountCommand command)
 {
     try
     {
         var eventData = _eventRepository.GetByAltId(command.EventId);
         if (eventData != null)
         {
             var eventDetails          = _eventDetailRepository.GetByEventId(eventData.Id);
             var eventTicketDetails    = _eventTicketDetailRepository.GetByEventDetailId(eventDetails.Id);
             var ticketCategories      = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => s.TicketCategoryId));
             var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetails.Select(s => s.Id));
             var placeWeekOpenDay      = _placeWeekOpenDaysRepository.GetByEventId(eventData.Id).FirstOrDefault();
             var dayTimeMappings       = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDay(placeWeekOpenDay.Id).FirstOrDefault();
             var eventCategoryMappings = _eventCategoryMappingRepository.GetByEventId(eventData.Id).FirstOrDefault();
             var subCategory           = _eventCategoryRepository.Get(eventCategoryMappings.EventCategoryId);
             var user           = _userRepository.GetByAltId(eventData.CreatedBy);
             var currencyType   = _currencyTypeRepository.Get(eventTicketAttributes.FirstOrDefault().CurrencyId);
             var eventAttribute = _eventAttributeRepository.GetByEventDetailId(eventDetails.Id);
             eventDetails.StartDateTime = _localTimeZoneConvertProvider.ConvertToLocal(eventDetails.StartDateTime, eventAttribute.TimeZone);
             var stripeConnectAccountId = command.IsStripeConnect ? _generateStripeConnectProvider.GenerateStripeAccessToken(command.AuthorizationCode, command.channels, eventData.Id) : null;
             if (stripeConnectAccountId != null && stripeConnectAccountId != "")
             {
                 var eventStripeConnect = _eventStripeConnectMasterRepository.GetByEventId(eventData.Id);
                 var eventStepDetails   = _stepProvider.SaveEventStepDetails(eventData.Id, 9, true, command.ModifiedBy);
                 var stripeConnnect     = new EventStripeConnectMaster
                 {
                     Id = eventStripeConnect != null ? eventStripeConnect.Id : 0,
                     StripeConnectAccountID = stripeConnectAccountId,
                     CreatedBy                = eventStripeConnect != null ? eventStripeConnect.CreatedBy : command.ModifiedBy,
                     CreatedUtc               = eventStripeConnect != null ? eventStripeConnect.CreatedUtc : DateTime.UtcNow,
                     ExtraCommisionFlat       = command.ExtraCommisionFlat,
                     ExtraCommisionPercentage = command.ExtraCommisionPercentage,
                     EventId    = eventData.Id,
                     IsEnabled  = true,
                     ModifiedBy = command.ModifiedBy,
                     UpdatedBy  = command.ModifiedBy,
                     UpdatedUtc = DateTime.UtcNow,
                 };
                 _eventStripeConnectMasterRepository.Save(stripeConnnect);
             }
             return(new StripeConnectAccountCommandResult
             {
                 Success = true,
                 EventTicketAttribute = eventTicketAttributes.ToList(),
                 DayTimeMappings = dayTimeMappings,
                 Event = eventData,
                 EventDetail = eventDetails,
                 EventTicketDetail = eventTicketDetails.ToList(),
                 TicketCategories = ticketCategories.ToList(),
                 ParentCategoryId = subCategory.EventCategoryId,
                 CurrencyType = currencyType,
                 Email = user.Email
             });
         }
         else
         {
             return(new StripeConnectAccountCommandResult {
             });
         }
     }
     catch (Exception e)
     {
         _logger.Log(FIL.Logging.Enums.LogCategory.Error, e);
         return(new StripeConnectAccountCommandResult {
         });
     }
 }
示例#10
0
        protected override async Task <ICommandResult> Handle(PaymentResponseCommand command)
        {
            IPaymentResponse paymentResponse = new PaymentResponse();

            try
            {
                var transactionProvider = _transactionIdProvider.Get(command.QueryString);
                if (transactionProvider.TransactionId == 0)
                {
                    return(new PaymentResponseCommandResult());
                }

                var paymentGateway = transactionProvider.PaymentGateway;
                TransactionPaymentDetail paymentDetail = null;
                if (!paymentGateway.HasValue)
                {
                    paymentDetail  = GetTransactionDetails(transactionProvider.TransactionId);
                    paymentGateway = paymentDetail.PaymentGatewayId;
                }

                var transaction = _transactionRepository.Get(transactionProvider.TransactionId);
                if (paymentGateway == PaymentGateway.Stripe)
                {
                    paymentDetail = paymentDetail ?? GetTransactionDetails(transactionProvider.TransactionId);
                    var currency = _currencyTypeRepository.Get(transaction.CurrencyId);
                    paymentResponse = await _stripeCharger.Charge(new StripeCharge
                    {
                        TransactionId    = transactionProvider.TransactionId,
                        Currency         = currency.Code,
                        Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                        UserCardDetailId = paymentDetail.UserCardDetailId ?? 0,
                        Token            = transactionProvider.Token,
                        ChannelId        = command.ChannelId
                    });
                }
                else if (paymentGateway == PaymentGateway.NabTransact)
                {
                    paymentResponse = await _nabTransactCharger.NabTransactResponseHandler(new GatewayCharge
                    {
                        QueryString = command.QueryString
                    });
                }
                else if (paymentGateway == PaymentGateway.HDFC)
                {
                    paymentResponse = _hdfcEnrolledCharger.HdfcResponseHandler(new GatewayCharge
                    {
                        QueryString = command.QueryString,
                        Response    = transactionProvider.Response
                    });
                }
                else if (paymentGateway == PaymentGateway.CCAvenue)
                {
                    paymentResponse = _ccavenueCharger.CcavenueResponseHandler(new GatewayCharge
                    {
                        QueryString = command.QueryString
                    });
                }

                return(new PaymentResponseCommandResult
                {
                    PaymentResponse = paymentResponse,
                    TransactionAltId = transaction.AltId,
                    Id = transactionProvider.TransactionId
                });
            }
            catch (Exception ex)
            {
                _logger.Log(FIL.Logging.Enums.LogCategory.Error, ex);
            }
            return(new PaymentResponseCommandResult());
        }
示例#11
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);
        }