Ejemplo n.º 1
0
        protected override async Task <ICommandResult> Handle(DeleteTicketCommand command)
        {
            try
            {
                var eventTicketDetail               = _eventTicketDetailRepository.GetByAltId(command.ETDAltId);
                var etdTicketCategoryMapping        = _eventTicketDetailTicketCategoryTypeMappingRepository.GeAlltByEventTicketDetail(eventTicketDetail.Id);
                var eventTicketAttribute            = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id);
                var ticketFeelDetails               = _ticketFeeDetailRepository.GetAllByEventTicketAttributeId(eventTicketAttribute.Id);
                var eventTicketDetailDiscountDetail = _eventTicketDiscountDetailRepository.GetAllByEventTicketAttributeId(eventTicketAttribute.Id);
                var transactionDetails              = _transactionDetailRepository.GetByEventTicketAttributeId(eventTicketAttribute.Id);

                if (!transactionDetails.Any())
                {
                    foreach (var etdTicketCat in etdTicketCategoryMapping)
                    {
                        _eventTicketDetailTicketCategoryTypeMappingRepository.Delete(etdTicketCat);
                    }

                    foreach (var ticketFeeDetail in ticketFeelDetails)
                    {
                        _ticketFeeDetailRepository.Delete(ticketFeeDetail);
                    }

                    foreach (var etdDiscount in eventTicketDetailDiscountDetail)
                    {
                        _eventTicketDiscountDetailRepository.Delete(etdDiscount);
                    }

                    if (eventTicketAttribute != null)
                    {
                        _eventTicketAttributeRepository.Delete(eventTicketAttribute);
                    }

                    if (eventTicketDetail != null)
                    {
                        _eventTicketDetailRepository.Delete(eventTicketDetail);
                    }

                    var eventStepDetails = _stepProvider.SaveEventStepDetails(command.EventId, command.CurrentStep, command.TicketLength == 1 ? false : true, command.ModifiedBy);
                    return(new DeleteTicketCommandResult
                    {
                        Success = true,
                        CompletedStep = eventStepDetails.CompletedStep,
                        CurrentStep = eventStepDetails.CurrentStep,
                    });
                }
                else
                {
                    return(new DeleteTicketCommandResult {
                        IsTicketSold = true
                    });
                }
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, e);
                return(new DeleteTicketCommandResult {
                });
            }
        }
Ejemplo n.º 2
0
        public GetticketDetailQueryResult Handle(GetticketDetailQuery query)
        {
            var eventTicketDetailDataModel = _eventTicketDetailRepository.GetByEventDetailId(query.EventDetailId);
            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 eventTicketAttributeIdList = eventTicketAttributeModel.Select(s => s.Id);
            var ticketFeeDetailIdDataModel = _ticketFeeDetail.GetByEventTicketAttributeIds(eventTicketAttributeIdList);
            var ticketFeeDetailModel       = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.TicketFeeDetail> >(ticketFeeDetailIdDataModel);

            return(new GetticketDetailQueryResult
            {
                EventTicketDetail = eventTicketDetailModel,
                EventTicketAttribute = eventTicketAttributeModel,
                TicketFeeDetail = ticketFeeDetailModel,
                TicketCategory = ticketCategoryModel,
            });
        }
Ejemplo n.º 3
0
        protected override async Task Handle(UpdateMatchLayoutCommand command)
        {
            var matchLayoutSectionModel = _matchLayoutSectionRepository.Get(command.SectionId);

            matchLayoutSectionModel.SectionName = command.SectionName;
            matchLayoutSectionModel.ModifiedBy  = command.ModifiedBy;
            matchLayoutSectionModel.EntryGateId = command.EntryGateId;
            matchLayoutSectionModel.Capacity    = command.Capacity;
            _matchLayoutSectionRepository.Save(matchLayoutSectionModel);

            var eventTicketDetailModel = _eventTicketDetailRepository.GetByTicketCategoryIdAndEventDetailId(matchLayoutSectionModel.TicketCategoryId, command.EventDetailId);

            if (eventTicketDetailModel != null)
            {
                var eventTicketAttributeModel = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetailModel.Id);
                eventTicketAttributeModel.Price                  = command.Price;
                eventTicketAttributeModel.CurrencyId             = command.CurrencyId;
                eventTicketAttributeModel.LocalPrice             = command.LocalPrice;
                eventTicketAttributeModel.LocalCurrencyId        = command.LocalCurrencyId;
                eventTicketAttributeModel.AvailableTicketForSale = command.Capacity;
                eventTicketAttributeModel.RemainingTicketForSale = command.Capacity;
                eventTicketAttributeModel.IsSeatSelection        = command.IsSeatSelection;
                eventTicketAttributeModel.ModifiedBy             = command.ModifiedBy;
                _eventTicketAttributeRepository.Save(eventTicketAttributeModel);
            }
        }
Ejemplo n.º 4
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 {
         });
     }
 }
Ejemplo n.º 5
0
        protected void UpdateAllOptions(SaveExOzProductOptionCommand command)
        {
            List <long> apiProductOptionIds = command.OptionList.Select(w => w.Id).ToList();
            var         exOzProductOptions  = _exOzProductOptionRepository.GetByOptionIds(apiProductOptionIds);

            var eventTicketDetailIds  = exOzProductOptions.Select(w => w.EventTicketDetailId).ToList();
            var FilEventTicketDetails = _eventTicketDetailRepository.GetByIds(eventTicketDetailIds);

            var ticketCategoryIds   = FilEventTicketDetails.Select(w => w.TicketCategoryId).ToList();
            var FilTicketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(ticketCategoryIds);

            foreach (var item in command.OptionList)
            {
                int optionCount = command.OptionList.Where(w => w.SessionId == item.SessionId).ToList().Count;
                try
                {
                    string TicketCategoryName = GetTicketCategoryName(item, optionCount);

                    ExOzProductOption  exOzProductOption  = exOzProductOptions.Where(w => w.ProductOptionId == item.Id).FirstOrDefault();
                    ExOzProductSession exOzProductSession = _exOzProductSessionRepository.GetBySessionId(item.SessionId);
                    ExOzProduct        exOzProduct        = _exOzProductRepository.Get(exOzProductSession.ProductId);

                    EventTicketDetail FilEventTicketDetail = FilEventTicketDetails.Where(w => w.Id == exOzProductOption.EventTicketDetailId).FirstOrDefault();
                    TicketCategory    FilTicketCategory    = FilTicketCategories.Where(w => w.Name == TicketCategoryName).FirstOrDefault();

                    TicketCategory retTicketCategory = UpdateTicketCategory(TicketCategoryName, FilTicketCategory, command.ModifiedBy);

                    EventTicketDetail retEventTicketDetail = UpdateEventTicketDetail(FilEventTicketDetail, exOzProduct.EventDetailId, retTicketCategory.Id, command.ModifiedBy);

                    EventTicketAttribute eventTicketAttribute = _eventTicketAttributeRepository.GetByEventTicketDetailId(retEventTicketDetail.Id);
                    EventTicketAttribute FilTicketAttribute   = UpdateEventTicketAttribute(item, eventTicketAttribute, retEventTicketDetail.Id, command.ModifiedBy);

                    TicketFeeDetail ticketFeeDetail     = _ticketFeeDetailRepository.GetByEventTicketAttributeId(FilTicketAttribute.EventTicketDetailId);
                    TicketFeeDetail FilTicketFeedDetail = UpdateTicketFeeDetails(ticketFeeDetail, FilTicketAttribute.Id, command.ModifiedBy);

                    ExOzProductOption retOption = updateProductOption(item, exOzProductOption, retEventTicketDetail.Id, exOzProductSession.Id, command.ModifiedBy);
                    updatedOptions.OptionList.Add(retOption);
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }
        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
            });
        }
Ejemplo n.º 7
0
        public BarcodeQueryResult Handle(BarcodeQuery query)
        {
            try
            {
                var eventTicketDetails = _eventTicketDetailRepository.GetRASVRideEventTicketDetails()
                                         .ToDictionary(k => k.Id, k => k);

                var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByBarcodeNumberAndEventTicketDetailIds(query.BarcodeNumber, eventTicketDetails.Keys);
                if (matchSeatTicketDetail != null)
                {
                    var transaction        = _transactionRepository.Get((long)matchSeatTicketDetail.TransactionId);
                    var eventTicketDetail  = eventTicketDetails[matchSeatTicketDetail.EventTicketDetailId];
                    var additionalInfo     = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id).AdditionalInfo;
                    var value              = JsonConvert.DeserializeObject <TicketValue>(additionalInfo).value;
                    var ticketCategoryId   = eventTicketDetail.TicketCategoryId;
                    var ticketCategoryName = _ticketCategoryRepository.Get((int)ticketCategoryId).Name.ToString();
                    var currencyId         = transaction.CurrencyId;
                    var transactionUTC     = transaction.CreatedUtc;
                    var currencyCode       = _currencyTypeRepository.GetById(currencyId).Code.ToString();
                    var userAltId          = transaction.CreatedBy;
                    var userId             = _userRepository.GetByAltId(userAltId).Id;
                    var userAddressDetail  = _userAddressDetailRepository.GetByUser(userId);
                    var zipcodeId          = userAddressDetail != null ? userAddressDetail.Zipcode : 9;
                    var postalcode         = _zipcodeRepository.Get(zipcodeId).Postalcode;

                    var barcodeDetailsContainer = new BarcodeDetailsContainer()
                    {
                        AltId            = (System.Guid)matchSeatTicketDetail.AltId,
                        BarcodeNumber    = matchSeatTicketDetail.BarcodeNumber,
                        CurrencyCode     = currencyCode,
                        TicketCategoryId = ticketCategoryId,
                        TicketCategory   = ticketCategoryName,
                        Value            = value,
                        Postalcode       = postalcode,
                        IsConsumed       = matchSeatTicketDetail.IsConsumed,
                        ConsumedDateTime = matchSeatTicketDetail.ConsumedDateTime,
                        TransactionUTC   = transactionUTC,
                    };
                    return(new BarcodeQueryResult
                    {
                        BarcodeDetailsContainer = barcodeDetailsContainer,
                        IsValid = true
                    });
                }

                var offlineBarcodeDetail = _offlineBarcodeDetailRepository.GetByBarcodeNumberAndEventTicketDetailIds(query.BarcodeNumber, eventTicketDetails.Keys);
                if (offlineBarcodeDetail != null)
                {
                    var ticketCategoryId = _eventTicketDetailRepository.Get(offlineBarcodeDetail.EventTicketDetailId)
                                           .TicketCategoryId;
                    var ticketCategoryName = _ticketCategoryRepository.Get((int)ticketCategoryId).Name;
                    var currencyCode       = _currencyTypeRepository.GetById(offlineBarcodeDetail.CurrencyId).Code;

                    var barcodeDetailsContainer = new BarcodeDetailsContainer
                    {
                        AltId            = offlineBarcodeDetail.AltId,
                        BarcodeNumber    = offlineBarcodeDetail.BarcodeNumber,
                        CurrencyCode     = currencyCode,
                        TicketCategoryId = ticketCategoryId,
                        TicketCategory   = ticketCategoryName,
                        Value            = offlineBarcodeDetail.Price,
                        Postalcode       = "",
                        IsConsumed       = offlineBarcodeDetail.IsConsumed,
                        ConsumedDateTime = offlineBarcodeDetail.ConsumedDateTime,
                    };
                    return(new BarcodeQueryResult
                    {
                        BarcodeDetailsContainer = barcodeDetailsContainer,
                        IsValid = true
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            return(new BarcodeQueryResult
            {
                BarcodeDetailsContainer = null,
                IsValid = false
            });
        }
Ejemplo n.º 8
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
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 {
         });
     }
 }
Ejemplo n.º 11
0
        public FeelEventLearnPageQueryResult Handle(FeelEventLearnPageQuery query)
        {
            EventLearnPageQueryResults eventLearnMorePage = new EventLearnPageQueryResults();

            if (!String.IsNullOrWhiteSpace(query.Slug))
            {
                eventLearnMorePage = _eventLearnPageProvider.GetBySlug(query.Slug);
            }
            else
            {
                eventLearnMorePage = _eventLearnPageProvider.GetByAltId(query.EventAltId);
            }

            if (eventLearnMorePage.Event != null)
            {
                var eventCategoryMappings = _eventCategoryMappingRepository.GetByEventId(eventLearnMorePage.Event.Id).FirstOrDefault();
                if (eventCategoryMappings == null)
                {
                    return(new FeelEventLearnPageQueryResult());
                }
                var subCategoryDataModel = _eventCategoryRepository.Get(eventCategoryMappings.EventCategoryId);
                var subCategory          = AutoMapper.Mapper.Map <Contracts.Models.EventCategory>(subCategoryDataModel);
                var categoryDataModel    = _eventCategoryRepository.Get(subCategory.EventCategoryId);
                var category             = AutoMapper.Mapper.Map <Contracts.Models.EventCategory>(categoryDataModel);

                var clientPointOfContact      = _clientPointOfContactRepository.Get(eventLearnMorePage.Event.ClientPointOfContactId);
                var clientPointOfContactModel = AutoMapper.Mapper.Map <Contracts.Models.ClientPointOfContact>(clientPointOfContact);

                var eventTicketDetails     = _eventTicketDetailRepository.GetByEventDetailId(eventLearnMorePage.EventDetail.Id).Where(s => s.IsEnabled == true);
                var EventTicketDetailModel = AutoMapper.Mapper.Map <List <Contracts.Models.EventTicketDetail> >(eventTicketDetails);

                var eventTicketCategories      = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => s.TicketCategoryId).Distinct());
                var eventTicketCategoriesModel = AutoMapper.Mapper.Map <List <Contracts.Models.TicketCategory> >(eventTicketCategories);

                var eventTicketAttributes      = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetails.Select(s => s.Id).Distinct());
                var eventTicketAttributesModel = AutoMapper.Mapper.Map <List <Contracts.Models.EventTicketAttribute> >(eventTicketAttributes);
                if (eventTicketAttributesModel.Count() == 0)
                {
                    return(new FeelEventLearnPageQueryResult {
                    });
                }
                var currencyMapping = _currencyTypeRepository.GetByCurrencyId(eventTicketAttributesModel.First().CurrencyId);

                var ratingDataModel = _ratingRepository.GetByEventId(eventLearnMorePage.Event.Id);
                var ratingModel     = AutoMapper.Mapper.Map <List <Contracts.Models.Rating> >(ratingDataModel);

                var userdataModel = _userRepository.GetByUserIds(ratingModel.Select(s => s.UserId).Distinct());
                var userModel     = AutoMapper.Mapper.Map <List <Contracts.Models.UserProfile> >(userdataModel);

                var           eventAmenities           = _eventAmenityRepository.GetByEventId(eventLearnMorePage.Event.Id);
                var           eventLearnMoreAttributes = _eventLearnMoreAttributeRepository.GetByEventId(eventLearnMorePage.Event.Id);
                var           learnMoreAttributes      = AutoMapper.Mapper.Map <List <Contracts.Models.EventLearnMoreAttribute> >(eventLearnMoreAttributes);
                var           ticketAlertEventMapping  = _ticketAlertEventMappingRepository.GetByEventId(eventCategoryMappings.EventId).FirstOrDefault();
                List <string> EventAmenitiesList       = new List <string>();
                foreach (var item in eventAmenities)
                {
                    var amenities = _amenityRepository.Get(item.AmenityId);
                    EventAmenitiesList.Add((amenities.Amenity).ToString());
                }
                var data = _calendarProvider.GetCalendarData(eventLearnMorePage.Event.Id);
                //For Hoho Routes
                var citySightSeeingRoute        = _citySightSeeingRouteRepository.GetByEventDetailId(eventLearnMorePage.EventDetail.Id);
                var citySightSeeingRouteDetails = _citySightSeeingRouteDetailRepository.GetByCitySightSeeingRouteIds(citySightSeeingRoute.Select(s => s.Id));

                //for Tiqets Places
                Contracts.Models.Tiqets.TiqetProductCheckoutDetail
                    tiqetCheckoutDetailsModel = new Contracts.Models.Tiqets.TiqetProductCheckoutDetail();
                if (eventLearnMorePage.Event.EventSourceId == EventSource.Tiqets)
                {
                    var tiqetEventDetailMapping = _tiqetEventDetailMappingRepository.GetByEventDetailId(eventLearnMorePage.EventDetail.Id);
                    var tiqetCheckoutDetails    = _tiqetProductCheckoutDetailRepository.GetByProductId(tiqetEventDetailMapping.ProductId);
                    tiqetCheckoutDetailsModel = Mapper.Map <Contracts.Models.Tiqets.TiqetProductCheckoutDetail>(tiqetCheckoutDetails);
                }

                //For Live Online Events
                List <EventHostMapping> eventHostMappings = new List <EventHostMapping>();
                DateTime formattedDateTime = new DateTime();
                string   eventDateTimeZome = string.Empty;
                if (eventLearnMorePage.Event.MasterEventTypeId == MasterEventType.Online)
                {
                    var eventHostMappingModel = _eventHostMappingRepository.GetAllByEventId(eventLearnMorePage.Event.Id);
                    eventHostMappings = AutoMapper.Mapper.Map <List <Contracts.Models.EventHostMapping> >(eventHostMappingModel);
                    var placeWeekOpenDays = _placeWeekOpenDaysRepository.GetByEventId(eventLearnMorePage.Event.Id).FirstOrDefault();
                    var dayTimeMapping    = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDay(placeWeekOpenDays.Id).FirstOrDefault();
                    var eventAttribute    = _eventAttributeRepository.GetByEventDetailId(eventLearnMorePage.EventDetail.Id);

                    //Getting Datetime for online Event
                    var eventDate      = _localTimeZoneConvertProvider.ConvertToLocal(eventLearnMorePage.EventDetail.StartDateTime, eventAttribute.TimeZone);
                    var dateTimeString = eventDate.ToString("yyyy/MM/dd") + " " + dayTimeMapping.StartTime + ":00.000";
                    formattedDateTime = DateTime.Parse(dateTimeString);

                    eventDateTimeZome = eventAttribute.TimeZoneAbbreviation;
                }
                return(new FeelEventLearnPageQueryResult
                {
                    EventType = (EventType)eventLearnMorePage.EventType,
                    EventCategory = eventLearnMorePage.EventCategory,
                    Event = eventLearnMorePage.Event,
                    EventDetail = eventLearnMorePage.EventDetail,
                    Venue = eventLearnMorePage.Venue,
                    City = eventLearnMorePage.City,
                    State = eventLearnMorePage.State,
                    Country = eventLearnMorePage.Country,
                    EventTicketAttribute = eventTicketAttributesModel,
                    EventTicketDetail = EventTicketDetailModel,
                    CurrencyType = Mapper.Map <CurrencyType>(currencyMapping),
                    Rating = ratingModel,
                    TicketCategory = eventTicketCategoriesModel,
                    User = userModel,
                    EventAmenitiesList = EventAmenitiesList,
                    ClientPointOfContact = clientPointOfContactModel,
                    EventGalleryImage = eventLearnMorePage.EventGalleryImage,
                    EventLearnMoreAttributes = learnMoreAttributes,
                    RegularTimeModel = data.RegularTimeModel,
                    SeasonTimeModel = data.SeasonTimeModel,
                    SpecialDayModel = data.SpecialDayModel,
                    Category = category,
                    SubCategory = subCategory,
                    CitySightSeeingRoutes = Mapper.Map <IEnumerable <FIL.Contracts.Models.CitySightSeeing.CitySightSeeingRoute> >(citySightSeeingRoute),
                    CitySightSeeingRouteDetails = Mapper.Map <IEnumerable <FIL.Contracts.Models.CitySightSeeing.CitySightSeeingRouteDetail> >(citySightSeeingRouteDetails),
                    TiqetsCheckoutDetails = tiqetCheckoutDetailsModel,
                    EventHostMappings = eventHostMappings,
                    OnlineStreamStartTime = formattedDateTime,
                    OnlineEventTimeZone = eventDateTimeZome,
                    TicketAlertEventMapping = ticketAlertEventMapping
                });
            }
            return(new FeelEventLearnPageQueryResult());
        }
Ejemplo n.º 12
0
        protected override async Task <ICommandResult> Handle(UpdateProductCommand command)
        {
            UpdateProductCommandResult updateCommandResult = new UpdateProductCommandResult();

            try
            {
                List <string> imageLinks      = new List <string>();
                var           tiqetProduct    = _tiqetProductRepository.GetByProductId(command.productId);
                var           checkoutDetails = await SaveCheckoutDetails(command);

                var countryandvenuedetails = await UpdateCountryAndVenueDetails(tiqetProduct.GeoLocationLatitude, tiqetProduct.GeoLocationLongitude, tiqetProduct.VenueName, tiqetProduct.VenueAddress, command.ModifiedBy, tiqetProduct.CountryName, tiqetProduct.CityName);

                bool isImageUpload = false;
                // Saving/Updating Details to our Tables
                var events        = _eventRepository.GetByEventName(tiqetProduct.Tittle);
                var formattedSlug = FormatSlug(tiqetProduct.Tittle);
                if (events == null)
                {
                    events = _eventRepository.Save(new Event
                    {
                        AltId                  = Guid.NewGuid(),
                        Name                   = tiqetProduct.Tittle,
                        EventCategoryId        = 29,
                        EventTypeId            = EventType.Perennial,
                        Description            = null,
                        ClientPointOfContactId = 1,
                        FbEventId              = null,
                        MetaDetails            = null,
                        IsFeel                 = true,
                        EventSourceId          = EventSource.Tiqets,
                        TermsAndConditions     = "",
                        IsPublishedOnSite      = true,
                        PublishedDateTime      = DateTime.Now,
                        PublishedBy            = null,
                        TestedBy               = null,
                        Slug                   = formattedSlug,
                        ModifiedBy             = command.ModifiedBy,
                        IsEnabled              = true
                    });
                    isImageUpload = true;
                }
                else
                {
                    events.IsEnabled   = true;
                    events.Description = tiqetProduct.Summary;
                    events.Slug        = formattedSlug;
                    _eventRepository.Save(events);
                }
                if (isImageUpload || command.IsImageUpload)
                {
                    var productImages = _tiqetProductImageRepository.GetByProductId(tiqetProduct.ProductId);
                    foreach (var currentImage in productImages)
                    {
                        imageLinks.Add(currentImage.Large);
                    }
                }
                var last = _eventSiteIdMappingRepository.GetAll().OrderByDescending(p => p.CreatedUtc).FirstOrDefault();
                var eventSiteIdMapping = _eventSiteIdMappingRepository.GetByEventId(events.Id);
                if (eventSiteIdMapping == null)
                {
                    _eventSiteIdMappingRepository.Save(new Contracts.DataModels.EventSiteIdMapping
                    {
                        EventId    = events.Id,
                        SortOrder  = Convert.ToInt16(last.SortOrder + 1),
                        SiteId     = Site.feelaplaceSite,
                        ModifiedBy = command.ModifiedBy,
                        IsEnabled  = true
                    });
                }
                var getEventCategoryId = await GetCategoryId(tiqetProduct.ProductId);

                foreach (var categoryId in getEventCategoryId)
                {
                    var eventCategoryMapping = _eventCategoryMappingRepository.GetByEventIdAndEventCategoryId(events.Id, categoryId);
                    if (eventCategoryMapping == null)
                    {
                        _eventCategoryMappingRepository.Save(new Contracts.DataModels.EventCategoryMapping
                        {
                            EventId         = events.Id,
                            EventCategoryId = categoryId,
                            ModifiedBy      = command.ModifiedBy,
                            IsEnabled       = true
                        });
                    }
                    else
                    {
                        eventCategoryMapping.EventCategoryId = categoryId;
                        _eventCategoryMappingRepository.Save(eventCategoryMapping);
                    }
                }
                var eventDetail = _eventDetailRepository.GetByNameAndVenueId(tiqetProduct.Tittle, countryandvenuedetails.venueId);
                if (eventDetail == null)
                {
                    eventDetail = _eventDetailRepository.Save(new EventDetail
                    {
                        Name                  = tiqetProduct.Tittle,
                        EventId               = events.Id,
                        VenueId               = countryandvenuedetails.venueId,
                        StartDateTime         = DateTime.UtcNow,
                        EndDateTime           = DateTime.UtcNow.AddYears(1),
                        GroupId               = 1,
                        AltId                 = Guid.NewGuid(),
                        TicketLimit           = 10,
                        ModifiedBy            = command.ModifiedBy,
                        IsEnabled             = true,
                        MetaDetails           = "",
                        HideEventDateTime     = false,
                        CustomDateTimeMessage = "",
                        CreatedUtc            = DateTime.UtcNow,
                        CreatedBy             = command.ModifiedBy
                    });
                }
                else
                {
                    eventDetail.IsEnabled     = true;
                    eventDetail.StartDateTime = DateTime.UtcNow;
                    eventDetail.EndDateTime   = DateTime.UtcNow.AddYears(1);
                    eventDetail.ModifiedBy    = command.ModifiedBy;
                    _eventDetailRepository.Save(eventDetail);
                }
                var eventDeliveryType = _eventDeliveryTypeDetailRepository.GetByEventDetailId(eventDetail.Id).ToList();
                if (eventDeliveryType.Count() == 0)
                {
                    _eventDeliveryTypeDetailRepository.Save(new EventDeliveryTypeDetail
                    {
                        EventDetailId  = eventDetail.Id,
                        DeliveryTypeId = DeliveryTypes.MTicket,
                        Notes          = "<table><tr><td valign=''top''>1.&nbsp;</td><td valign=''top''>Ticket pickup location and timing will be announced in the “Customer Update” sectionof our website closer to the event. Please check that regularly.</td></tr><tr><td valign=''top''>2.&nbsp;</td><td valign=''top''>The following documents are compulsory for ticket pickup:<br /><table><tr>  <td valign=''top''>  a.&nbsp;  </td>  <td colspan=''2'' valign=''top''>  The card / bank account owner’s original Govt. issued photo ID, along with a clean,  fully legible, photocopy of the same ID  </td></tr><tr>  <td valign=''top''>  b.&nbsp;  </td>  <td colspan=''2'' valign=''top''>  When a debit or credit card has been used for purchase, we also need the original  debit/credit card, along with a clean, fully legible, photocopy of the same card  </td></tr><tr>  <td valign=''top''>  c.&nbsp;  </td>  <td colspan=''2'' valign=''top''>  If sending someone else on behalf of the card holder / bank account owner, then  we need numbers 2.a. and 2.b above (originals and photocopies as mentioned) along  with the following below. This is required even if the representative’s name has  been entered into the system when buying:  </td></tr><tr>  <td valign=''top''>  </td>  <td valign=''top''>  i.&nbsp;  </td>  <td>  An authorization letter with the name of the representative, signed by the card  holder/bank account owner  </td></tr><tr>  <td valign=''top''>  </td>  <td valign=''top''>  ii.&nbsp;  </td>  <td>  A Govt issued photo ID of the representative, along with a clean and legible photocopy  of the same photo identification  </td></tr></table></td></tr><tr><td valign=''top''>3.&nbsp;</td><td valign=''top''>Please note, absence of any one of the documents above can result in the tickets being refused at the ticket pickup window</td></tr>  </table>",
                        EndDate        = DateTime.UtcNow.AddYears(1),
                        ModifiedBy     = command.ModifiedBy,
                        IsEnabled      = true,
                        CreatedUtc     = DateTime.UtcNow
                    });
                }

                await GetVariantDetails(tiqetProduct.ProductId);
                await DisableAllEventTicketDetailMappings(tiqetProduct.ProductId);

                var variantdetails = _tiqetVariantDetailRepository.GetAllByProductId(tiqetProduct.ProductId);
                //if variants are not available at the moment disable it.
                if (variantdetails.Count() == 0)
                {
                    events.IsEnabled = false;
                    _eventRepository.Save(events);
                    eventDetail.IsEnabled = false;
                    _eventDetailRepository.Save(eventDetail);
                    updateCommandResult.success = false;
                    return(updateCommandResult);
                }
                foreach (var variantdetail in variantdetails)
                {
                    //eventTicketDetails and TicketCategories goes here
                    var ticketCategory = _ticketCategoryRepository.GetByName(variantdetail.Label);
                    if (ticketCategory == null)
                    {
                        ticketCategory = _ticketCategoryRepository.Save(new TicketCategory
                        {
                            Name       = variantdetail.Label,
                            ModifiedBy = command.ModifiedBy,
                            IsEnabled  = true
                        });
                    }
                    var eventTicketDetail = _eventTicketDetailRepository.GetByTicketCategoryIdAndEventDetailId(ticketCategory.Id, eventDetail.Id);
                    if (eventTicketDetail == null)
                    {
                        eventTicketDetail = _eventTicketDetailRepository.Save(new EventTicketDetail
                        {
                            EventDetailId    = eventDetail.Id,
                            TicketCategoryId = ticketCategory.Id,
                            ModifiedBy       = command.ModifiedBy,
                            IsEnabled        = true
                        });
                    }
                    else
                    {
                        eventTicketDetail.IsEnabled = true;
                        _eventTicketDetailRepository.Save(eventTicketDetail);
                    }

                    var eventTicketDetailMapping = await SaveToTiqetsEventTicketDetailMapping(variantdetail.Id, eventTicketDetail.Id, command);

                    var eventTicketAttribute = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id);
                    if (eventTicketAttribute == null)
                    {
                        eventTicketAttribute = _eventTicketAttributeRepository.Save(new EventTicketAttribute
                        {
                            EventTicketDetailId       = eventTicketDetail.Id,
                            SalesStartDateTime        = DateTime.UtcNow,
                            SalesEndDatetime          = DateTime.UtcNow.AddYears(1),
                            TicketTypeId              = TicketType.Regular,
                            ChannelId                 = Channels.Feel,
                            CurrencyId                = TiqetsConstant.CurrencyCode,
                            SharedInventoryGroupId    = null,
                            TicketCategoryDescription = "",
                            ViewFromStand             = "",
                            IsSeatSelection           = false,
                            AvailableTicketForSale    = Convert.ToInt32(variantdetail.MaxTicketsPerOrder),
                            RemainingTicketForSale    = Convert.ToInt32(variantdetail.MaxTicketsPerOrder),
                            Price = variantdetail.TotalRetailPriceInclVat,
                            IsInternationalCardAllowed = false,
                            IsEMIApplicable            = false,
                            ModifiedBy = command.ModifiedBy,
                            IsEnabled  = true
                        });
                    }
                    else
                    {
                        eventTicketAttribute.SalesStartDateTime     = DateTime.UtcNow;
                        eventTicketAttribute.SalesEndDatetime       = DateTime.UtcNow.AddYears(1);
                        eventTicketAttribute.AvailableTicketForSale = Convert.ToInt32(variantdetail.MaxTicketsPerOrder);
                        eventTicketAttribute.RemainingTicketForSale = Convert.ToInt32(variantdetail.MaxTicketsPerOrder);
                        eventTicketAttribute.Price = variantdetail.TotalRetailPriceInclVat;
                        _eventTicketAttributeRepository.Save(eventTicketAttribute);
                    }
                    var ticketFeeDetail = _ticketFeeDetailRepository.GetByEventTicketAttributeIdAndFeedId(eventTicketAttribute.Id, (int)FeeType.ConvenienceCharge);
                    if (ticketFeeDetail == null)
                    {
                        ticketFeeDetail = _ticketFeeDetailRepository.Save(new TicketFeeDetail
                        {
                            EventTicketAttributeId = eventTicketAttribute.Id,
                            FeeId       = (int)FeeType.ConvenienceCharge,
                            DisplayName = "Convienence Charge",
                            ValueTypeId = (int)ValueTypes.Percentage,
                            Value       = 5,
                            ModifiedBy  = command.ModifiedBy,
                            IsEnabled   = true
                        });
                    }
                }
                await DisableEventTicketDeails(tiqetProduct.ProductId);
                await SaveToEventDetailMapping(tiqetProduct.ProductId, eventDetail.Id);
                await SyncDaysAvailabilityAsync(command, eventDetail.Id, events.Id);

                updateCommandResult.IsImageUpload = imageLinks.Count() > 0 ? true : false;
                updateCommandResult.success       = true;
                updateCommandResult.ImageLinks    = imageLinks;
                updateCommandResult.EventAltId    = events.AltId;
                return(updateCommandResult);
            }
            catch (Exception e)
            {
                updateCommandResult.success       = false;
                updateCommandResult.IsImageUpload = false;
                _logger.Log(LogCategory.Error, new Exception("Failed to update Product Details", e));
                return(updateCommandResult);
            }
        }
Ejemplo n.º 13
0
        public void SaveTicketDetail(ChauffeurRoute route, EventDetail eventDetail, SaveLocationReturnValues cityAndCurrency)
        {
            var category = "Passengers";

            try
            {
                var ticketCategory = _ticketCategoryRepository.GetByName(category);
                if (ticketCategory == null)
                {
                    ticketCategory = _ticketCategoryRepository.Save(new TicketCategory
                    {
                        Name       = category,
                        ModifiedBy = eventDetail.ModifiedBy,
                        IsEnabled  = true
                    });
                }

                var eventTicketDetail = _eventTicketDetailRepository.GetByTicketCategoryIdAndEventDetailId(ticketCategory.Id, eventDetail.Id);
                if (eventTicketDetail == null)
                {
                    eventTicketDetail = _eventTicketDetailRepository.Save(new EventTicketDetail
                    {
                        EventDetailId    = eventDetail.Id,
                        TicketCategoryId = ticketCategory.Id,
                        ModifiedBy       = eventDetail.ModifiedBy,
                        IsEnabled        = true
                    });
                }

                var eventTicketAttributeIn = new EventTicketAttribute
                {
                    EventTicketDetailId       = eventTicketDetail.Id,
                    SalesStartDateTime        = eventDetail.StartDateTime,
                    SalesEndDatetime          = eventDetail.EndDateTime,
                    TicketTypeId              = TicketType.Regular,
                    ChannelId                 = Channels.Feel,
                    CurrencyId                = cityAndCurrency.currencyId,
                    SharedInventoryGroupId    = null,
                    TicketCategoryDescription = $"Chauffeur Service Price from {route.LocationHeader}",
                    ViewFromStand             = string.Empty,
                    IsSeatSelection           = false,
                    AvailableTicketForSale    = 50,
                    RemainingTicketForSale    = 50,
                    Price = Convert.ToDecimal(route.ReturnPrice) < 0 ? 0 : Convert.ToDecimal(route.ReturnPrice),
                    IsInternationalCardAllowed = false,
                    IsEMIApplicable            = false,
                    ModifiedBy = eventDetail.ModifiedBy,
                    IsEnabled  = true
                };

                var eventTicketAttributeOut = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id);

                if (eventTicketAttributeOut == null)
                {
                    eventTicketAttributeOut = _eventTicketAttributeRepository.Save(eventTicketAttributeIn);
                }
                else
                {
                    eventTicketAttributeOut.Price = Convert.ToDecimal(route.ReturnPrice) < 0 ? 0 : Convert.ToDecimal(route.ReturnPrice);
                    eventTicketAttributeOut       = _eventTicketAttributeRepository.Save(eventTicketAttributeIn);
                }

                var ticketFeeDetail = _ticketFeeDetailRepository.GetByEventTicketAttributeIdAndFeedId(eventTicketAttributeOut.Id, (int)FeeType.ConvenienceCharge);
                if (ticketFeeDetail == null)
                {
                    ticketFeeDetail = _ticketFeeDetailRepository.Save(new TicketFeeDetail
                    {
                        EventTicketAttributeId = eventTicketAttributeOut.Id,
                        FeeId       = (int)FeeType.ConvenienceCharge,
                        DisplayName = "Convienence Charge",
                        ValueTypeId = (int)ValueTypes.Percentage,
                        Value       = 5,
                        ModifiedBy  = eventDetail.ModifiedBy,
                        IsEnabled   = true
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, ex);
            }
        }