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 { }); } }
public GetPlaceInventoryQueryResult Handle(GetPlaceInventoryQuery query) { try { var eventData = _eventRepository.GetByAltId(query.PlaceAltId); var eventModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.Event>(eventData); List <string> TicketValidityTypes = new List <string>(); List <string> DeliveryTypes = new List <string>(); foreach (FIL.Contracts.Enums.TicketValidityTypes ticketValidity in Enum.GetValues(typeof(FIL.Contracts.Enums.TicketValidityTypes))) { TicketValidityTypes.Add(ticketValidity.ToString()); } foreach (FIL.Contracts.Enums.DeliveryTypes DeliveryType in Enum.GetValues(typeof(FIL.Contracts.Enums.DeliveryTypes))) { DeliveryTypes.Add(DeliveryType.ToString()); } var eventDetail = _eventDetailRepository.GetAllByEventId(eventData.Id); var eventDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventDetail> >(eventDetail).Where(s => s.IsEnabled == true).ToList(); var eventTicketDetils = _eventTicketDetail.GetByEventDetailId(eventDetail.ElementAt(0).Id).Where(s => s.IsEnabled == true); var eventAttribute = _eventAttributeRepository.GetByEventDetailId(eventDetail.FirstOrDefault().Id); var EventTicketDetailTicketCategoryTypeMappingDataModel = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(eventTicketDetils.Select(s => s.Id).ToList()).Where(s => s.IsEnabled == true); var EventTicketDetailTicketCategoryTypeMappingModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventTicketDetailTicketCategoryTypeMapping> >(EventTicketDetailTicketCategoryTypeMappingDataModel); var ticketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetils.Select(s => s.TicketCategoryId)).Where(s => s.IsEnabled == true); var placeCustomerDocumentTypes = _placeCustomerDocumentTypeMappingRepository.GetAllByEventId(eventData.Id); var placeCustomerDocumentTypeModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceCustomerDocumentTypeMapping> >(placeCustomerDocumentTypes); var placeTicketRedemptionDetails = _placeTicketRedemptionDetailRepository.GetAllByEventDetailIds(eventDetail.Select(s => s.Id)); var placeTicketRedemptionDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceTicketRedemptionDetail> >(placeTicketRedemptionDetails); var placeDeliveryTypes = _eventDeliveryTypeDetailRepository.GetByEventDetailId(eventDetail.ElementAt(0).Id); var placeDeliveryTypesModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventDeliveryTypeDetail> >(placeDeliveryTypes); var customerDoumentType = _customerDocumentTypeRepository.GetAll(); var customerDoumentTypeModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.CustomerDocumentType> >(customerDoumentType); var placeHolidayDates = _placeHolidydates.GetAllByEventId(eventData.Id); var placeHolidayDatesModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceHolidayDate> >(placeHolidayDates); var placeWeekOffs = _placeWeekOffRepository.GetAllByEventId(eventData.Id); var placeWeekOffsModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceWeekOff> >(placeWeekOffs); var customerInformationMapping = _customerInformationRepository.GetAll(); var customerInformationMappingModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.CustomerInformation> >(customerInformationMapping); var eventCustomerInformationMapping = _eventCustomerInformationMappingRepository.GetAllByEventID(eventModel.Id).ToList(); List <FIL.Contracts.Models.EventCustomerInformationMapping> eventCustomerInformationMappingModel = new List <Contracts.Models.EventCustomerInformationMapping>();; if (eventCustomerInformationMapping.Count() > 0) { eventCustomerInformationMappingModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventCustomerInformationMapping> >(eventCustomerInformationMapping); } List <FIL.Contracts.DataModels.EventTicketDetail> etdList = new List <FIL.Contracts.DataModels.EventTicketDetail>(); foreach (FIL.Contracts.DataModels.EventTicketDetail currentTicketCat in eventTicketDetils.ToList()) { /*--------------- Add those ETD whose eventticketdetail and ETA exists */ var etaData = _eventTicketAttribute.GetByEventTicketDetailIdFeelAdmin(currentTicketCat.Id); if (etaData != null) { etdList.Add(currentTicketCat); } } var ticketCategoryContainer = etdList.Select(td => { try { var ticketDetailModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.EventTicketDetail>(td); var ticketCategory = _ticketCategoryRepository.Get((int)td.TicketCategoryId); var ticketCategoryModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.TicketCategory>(ticketCategory); var eventTicketAttributes = _eventTicketAttribute.GetByEventTicketDetailIdFeelAdmin(td.Id); var eventTicketAttributeModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.EventTicketAttribute>(eventTicketAttributes); var TicketCategoryTypeTypeMapping = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetail(td.Id); var ticketFeeDetail = _ticketFeeDetailRepository.GetAllByEventTicketAttributeId(eventTicketAttributeModel.Id); var ticketFeeDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TicketFeeDetail> >(ticketFeeDetail); return(new TicketCategoryInfo { TicketCategory = ticketCategoryModel, EventTicketAttribute = eventTicketAttributeModel, EventTicketDetail = ticketDetailModel, TicketCategorySubTypeId = (TicketCategoryTypeTypeMapping != null ? TicketCategoryTypeTypeMapping.TicketCategorySubTypeId : 1), TicketCategoryTypeId = (TicketCategoryTypeTypeMapping != null ? TicketCategoryTypeTypeMapping.TicketCategoryTypeId : 1), TicketFeeDetails = ticketFeeDetailModel }); } catch (Exception e) { return(new TicketCategoryInfo { }); } }).ToList(); var data = _calendarProvider.GetCalendarData(eventData.Id); return(new GetPlaceInventoryQueryResult { Event = eventModel, EventDetails = eventDetailModel, TicketCategoryContainer = ticketCategoryContainer, PlaceCustomerDocumentTypeMappings = placeCustomerDocumentTypeModel, DeliveryTypes = DeliveryTypes, eventDeliveryTypeDetails = placeDeliveryTypesModel, EventTicketDetailTicketCategoryTypeMappings = EventTicketDetailTicketCategoryTypeMappingModel, PlaceTicketRedemptionDetails = placeTicketRedemptionDetailModel, TicketValidityTypes = TicketValidityTypes, CustomerDocumentTypes = customerDoumentTypeModel, PlaceHolidayDates = placeHolidayDatesModel, PlaceWeekOffs = placeWeekOffsModel, CustomerInformations = customerInformationMappingModel, EventCustomerInformationMappings = eventCustomerInformationMappingModel, RegularTimeModel = data.RegularTimeModel, SeasonTimeModel = data.SeasonTimeModel, SpecialDayModel = data.SpecialDayModel, EventAttribute = eventAttribute }); } catch (Exception e) { return(new GetPlaceInventoryQueryResult { }); } }
public TicketQueryResult Handle(TicketQuery query) { try { List <FIL.Contracts.Models.CreateEventV1.TicketModel> ticketModelList = new List <FIL.Contracts.Models.CreateEventV1.TicketModel>(); var currentEvent = _eventRepository.Get(query.EventId); if (currentEvent == null) { return(new TicketQueryResult { Success = true }); } var eventDetail = _eventDetailRepository.GetByEventId(query.EventId); if (eventDetail == null) { return(new TicketQueryResult { Success = true, IsDraft = true, IsValidLink = true, Tickets = ticketModelList }); } var eventTicketDetails = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.Id); var eventTicketDetailTicketCategoryMappingData = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(eventTicketDetails.Select(s => s.Id).ToList()).ToList(); if (query.TicketCategoryTypeId == 2) { eventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.TicketCategoryTypeId == 2).ToList(); eventTicketDetails = eventTicketDetails.Where(p => eventTicketDetailTicketCategoryMappingData.Any(p2 => p2.EventTicketDetailId == p.Id) || (p.TicketCategoryId == 19452 || p.TicketCategoryId == 12259)); if (!eventTicketDetails.Any()) { return(new TicketQueryResult { EventDetailId = eventDetail.Id, EventId = currentEvent.Id, Success = true, IsValidLink = true, Tickets = ticketModelList }); } } else { eventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.TicketCategoryTypeId != 2).ToList(); eventTicketDetails = eventTicketDetails.Where(p => eventTicketDetailTicketCategoryMappingData.Any(p2 => p2.EventTicketDetailId == p.Id)); } var ticketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => s.TicketCategoryId)); var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => s.Id)); var currency = _currencyTypeRepository.GetByCurrencyIds(eventTicketAttributes.Select(s => s.CurrencyId).ToList()); var eventTicketDiscountDetails = _eventTicketDiscountDetailRepository.GetAllByEventTicketAttributeIds(eventTicketAttributes.Select(s => s.Id).ToList()); var discounts = _discountRepository.GetAllDiscountsByIds(eventTicketDiscountDetails.Select(s => (long)s.DiscountId).ToList()); var discountPromoCodes = _discountPromoCodeRepository.GetAllDiscountIds(discounts.Select(s => (long)s.Id).ToList()); foreach (var currentEventTicketDetail in eventTicketDetails) { FIL.Contracts.Models.CreateEventV1.TicketModel newTicketModel = new FIL.Contracts.Models.CreateEventV1.TicketModel(); var currentTicketCat = ticketCategories.Where(s => s.Id == currentEventTicketDetail.TicketCategoryId).FirstOrDefault(); var currentEventTicketAttribute = eventTicketAttributes.Where(s => s.EventTicketDetailId == currentEventTicketDetail.Id).FirstOrDefault(); var currentEventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.EventTicketDetailId == currentEventTicketDetail.Id).FirstOrDefault(); var currentEventTicketDiscountDetails = eventTicketDiscountDetails.Where(s => s.EventTicketAttributeId == currentEventTicketAttribute.Id).FirstOrDefault(); var currentDiscount = currentEventTicketDiscountDetails != null?discounts.Where(s => s.Id == currentEventTicketDiscountDetails.DiscountId).FirstOrDefault() : null; var currentDiscountPromoCodes = currentDiscount != null?discountPromoCodes.Where(s => s.DiscountId == currentDiscount.Id).FirstOrDefault() : null; var donationDetail = new FIL.Contracts.DataModels.DonationDetail(); if (currentEventTicketDetail.TicketCategoryId == 19452 || currentEventTicketDetail.TicketCategoryId == 12259) { donationDetail = _donationDetailRepository.GetByEventId(query.EventId); } newTicketModel.TicketAltId = currentEventTicketDetail.AltId; newTicketModel.ETDId = currentEventTicketDetail.Id; newTicketModel.TicketCategoryId = currentTicketCat.Id; newTicketModel.Name = currentTicketCat.Name; newTicketModel.Price = currentEventTicketAttribute.Price; newTicketModel.Quantity = currentEventTicketAttribute.AvailableTicketForSale; newTicketModel.Description = currentEventTicketAttribute.TicketCategoryDescription; newTicketModel.CurrencyId = currentEventTicketAttribute.CurrencyId; newTicketModel.TicketCategoryTypeId = currentEventTicketDetailTicketCategoryMappingData == null ? 1 : (currentEventTicketDetailTicketCategoryMappingData != null && currentEventTicketDetailTicketCategoryMappingData.TicketCategoryTypeId == 1) ? 1 : 2; newTicketModel.isEnabled = currentEventTicketDetail.IsEnabled; newTicketModel.CurrencyCode = currency.Where(s => s.Id == currentEventTicketAttribute.CurrencyId).FirstOrDefault().Code; newTicketModel.TotalQuantity = currentEventTicketAttribute.AvailableTicketForSale; newTicketModel.RemainingQuantity = currentEventTicketAttribute.RemainingTicketForSale; newTicketModel.DiscountAmount = currentDiscount != null && currentDiscount.DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat ? currentDiscount.DiscountValue : 0; newTicketModel.IsDiscountEnable = currentEventTicketDiscountDetails != null ? currentEventTicketDiscountDetails.IsEnabled : false; newTicketModel.DiscountPercentage = currentDiscount != null && currentDiscount.DiscountValueTypeId == Contracts.Enums.DiscountValueType.Percentage ? currentDiscount.DiscountValue : 0; newTicketModel.PromoCode = currentDiscountPromoCodes != null ? currentDiscountPromoCodes.PromoCode : null; newTicketModel.DiscountValueType = currentDiscount != null ? currentDiscount.DiscountValueTypeId : Contracts.Enums.DiscountValueType.Flat; newTicketModel.DonationAmount1 = donationDetail != null ? donationDetail.DonationAmount1 : 0; newTicketModel.DonationAmount2 = donationDetail != null ? donationDetail.DonationAmount2 : 0; newTicketModel.DonationAmount3 = donationDetail != null ? donationDetail.DonationAmount3 : 0; ticketModelList.Add(newTicketModel); } return(new TicketQueryResult { EventDetailId = eventDetail.Id, EventId = currentEvent.Id, Success = true, IsValidLink = true, Tickets = ticketModelList }); } catch (Exception e) { return(new TicketQueryResult { }); } }
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 { }); } }
public FeelCategoryEventQueryResult Handle(FeelCategoryEventQuery query) { try { query.SiteId = FIL.Contracts.Enums.Site.feelaplaceSite; var countryDescription = new FIL.Contracts.DataModels.CountryDescription(); var cityDescription = new FIL.Contracts.DataModels.CityDescription(); var countryContents = new List <FIL.Contracts.DataModels.CountryContentMapping>(); var indexEventId = eventIdProvider(query); var siteEvents = _eventSiteIdMappingRepository .GetBySiteId(query.SiteId) .OrderBy(o => o.SortOrder).ToList(); var categoryEvents = _eventRepository.GetByAllEventIds(indexEventId) .Where(e => e.IsEnabled) .ToList(); var eventMapping = categoryEvents.ToDictionary(e => e.Id); var eventIds = eventMapping.Keys; var eventCategoryMappings = _eventCategoryMappingRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled == true); var allEventDetails = _eventDetailRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled == true); var allEventAttributes = _eventAttributeRepository.GetByEventDetailIds(allEventDetails.Select(s => s.Id)); var allEventTicketDetails = _eventTicketDetailRepository.GetAllByEventDetailIds(allEventDetails.Select(s => s.Id)); var allEventTicketDetailTicketCategoryTypeMapping = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(allEventTicketDetails.Select(s => s.Id).ToList()).Where(s => s.TicketCategoryTypeId == 2); allEventTicketDetails = allEventTicketDetails.Where(s => allEventTicketDetailTicketCategoryTypeMapping.All(p => p.EventTicketDetailId != s.Id)); var allLiveEventDetails = _liveEventDetailRepository.GetAllByEventIds(eventIds.ToList()); var allEventRatings = _ratingRepository.GetByEventIds(eventIds); var venueMapping = _venueRepository.GetByVenueIds(allEventDetails.Select(ed => ed.VenueId).Distinct()) .ToDictionary(v => v.Id); var eventDetailsMapping = allEventDetails.GroupBy(ed => ed.EventId) .ToDictionary(g => g.Key, g => g.ToList()); var eventCategoryMapping = eventCategoryMappings.GroupBy(ed => ed.EventId) .ToDictionary(g => g.Key, g => g.ToList()); var eventRatingMapping = allEventRatings.GroupBy(ed => ed.EventId) .ToDictionary(g => g.Key, g => g.ToList()); var cityIds = venueMapping.Values.Select(s => s.CityId).Distinct(); var allCities = _cityRepository.GetByCityIds(cityIds); var cityMapping = allCities.ToDictionary(c => c.Id); var stateId = cityMapping.Values.Select(c => c.StateId).Distinct(); var stateMapping = _stateRepository.GetByStateIds(stateId) .ToDictionary(s => s.Id); var countryIdList = stateMapping.Values.Select(s => s.CountryId).Distinct(); var countryMapping = _countryRepository.GetByCountryIds(countryIdList) .ToDictionary(c => c.Id); if (query.IsCountryLandingPage) { if (countryIdList.ToList().Any()) { countryDescription = _countryDescriptionRepository.GetByCountryId(countryIdList.ToList().ElementAt(0)); countryContents = _countryContentMappingRepository.GetByCountryId(countryIdList.ToList().ElementAt(0)).ToList(); } } if (query.IsCityLandingPage) { if (cityIds.ToList().Any()) { var cities = _cityRepository.GetAllByName(allCities.ElementAt(0).Name); foreach (var currentCity in allCities) { cityDescription = _cityDescriptionRepository.GetBycityId(currentCity.Id); if (cityDescription != null) { break; } } } } var eventsBySortOrder = new List <FIL.Contracts.DataModels.Event>(); foreach (var item in siteEvents) { var events = categoryEvents.FirstOrDefault(w => w.Id == item.EventId); if (events != null) { eventsBySortOrder.Add(AutoMapper.Mapper.Map <FIL.Contracts.DataModels.Event>(events)); } } eventsBySortOrder = eventsBySortOrder.Where(s => !s.IsTokenize).ToList(); var CategoryEventData = eventsBySortOrder.Select(ce => { try { var eventObj = eventMapping[ce.Id]; var EventCategory = eventObj.EventCategoryId.ToString(); var parentCategory = ""; var eventDetails = eventDetailsMapping[ce.Id]; var eventAttribute = allEventAttributes.Where(s => s.EventDetailId == eventDetails.FirstOrDefault().Id).FirstOrDefault(); var eventTicketDetails = allEventTicketDetails.Where(s => eventDetails.Exists(p => p.Id == s.EventDetailId)); var eventCategoryMap = eventCategoryMapping[ce.Id]; if (eventCategoryMap.Any()) { var eventCategory = _eventCategoryRepository.Get(eventCategoryMap.FirstOrDefault().EventCategoryId); if (eventCategory != null) { EventCategory = eventCategory.Slug; var parentCategoryModel = _eventCategoryRepository.Get(eventCategory.EventCategoryId); parentCategory = parentCategoryModel.Slug; } } List <FIL.Contracts.DataModels.Rating> eventRatings; if (eventRatingMapping.ContainsKey(ce.Id)) { eventRatings = eventRatingMapping[ce.Id]; } else { eventRatings = null; } var eventDetailIdList = eventDetails.Select(s => s.Id).Distinct().ToList(); var eventTicketDetailIdList = eventTicketDetails.Select(s => s.Id).Distinct().ToList(); var venues = eventDetails.Select(s => s.VenueId).Distinct().Select(v => venueMapping[v]); var cities = venues.Select(s => s.CityId).Distinct().Select(c => cityMapping[c]); var states = cities.Select(s => s.StateId).Distinct().Select(s => stateMapping[s]); var countries = states.Select(s => s.CountryId).Distinct().Select(c => countryMapping[c]); var eventTicketAttributeMapping = new List <Contracts.DataModels.EventTicketAttribute> { _eventTicketAttributeRepository.GetMaxPriceByEventTicketDetailId(eventTicketDetailIdList), _eventTicketAttributeRepository.GetMinPriceByEventTicketDetailId(eventTicketDetailIdList) }; var currencyMapping = _currencyTypeRepository.GetByCurrencyId(eventTicketAttributeMapping.Where(s => s.IsEnabled == true).ToList().First().CurrencyId); List <string> eventCatMappings = new List <string>(); var eventCategoryDataModel = _eventCategoryRepository.GetByIds(eventCategoryMap.Select(s => s.EventCategoryId)); foreach (var eventCat in eventCategoryDataModel) { eventCatMappings.Add(eventCat.DisplayName); } var localDateTime = eventDetails.FirstOrDefault().StartDateTime.DayOfWeek + ", " + eventDetails.FirstOrDefault().StartDateTime.ToString(@"MMM dd, yyyy HH:mm", new CultureInfo("en-US")).ToUpper(); if (eventAttribute != null) { localDateTime = eventDetails.FirstOrDefault().StartDateTime.DayOfWeek + ", " + _localTimeZoneConvertProvider.ConvertToLocal(eventDetails.FirstOrDefault().StartDateTime, eventAttribute.TimeZone).ToString(@"MMM dd, yyyy HH:mm", new CultureInfo("en-US")).ToUpper(); } return(new CategoryEventContainer { CategoryEvent = Mapper.Map <Contracts.Models.CategoryEvent>(ce), EventType = eventObj.EventTypeId.ToString(), EventCategory = EventCategory, City = Mapper.Map <IEnumerable <City> >(cities), State = Mapper.Map <IEnumerable <State> >(states), Country = Mapper.Map <IEnumerable <Country> >(countries), Event = Mapper.Map <Event>(eventObj), EventDetail = Mapper.Map <IEnumerable <EventDetail> >(eventDetails), Rating = Mapper.Map <IEnumerable <Rating> >(eventRatings), CurrencyType = Mapper.Map <CurrencyType>(currencyMapping), Venue = Mapper.Map <IEnumerable <Venue> >(venues), EventTicketAttribute = Mapper.Map <IEnumerable <EventTicketAttribute> >(eventTicketAttributeMapping), EventCategories = eventCatMappings, LocalStartDateTime = localDateTime, TimeZoneAbbrivation = eventAttribute != null ? eventAttribute.TimeZoneAbbreviation : "UTC", EventFrequencyType = eventDetails.FirstOrDefault().EventFrequencyType, ParentCategory = parentCategory, LiveEventDetail = allLiveEventDetails.Where(s => s.EventId == ce.Id).FirstOrDefault() }); } catch (Exception e) { return(new CategoryEventContainer { }); } }); return(new FeelCategoryEventQueryResult { CategoryEvents = CategoryEventData.ToList(), CountryDescription = Mapper.Map <Contracts.Models.CountryDescription>(countryDescription), CityDescription = cityDescription, CountryContentMapping = Mapper.Map <List <CountryContentMapping> >(countryContents) }); } catch (Exception e) { return(new FeelCategoryEventQueryResult { }); } }