Beispiel #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 {
                });
            }
        }
Beispiel #2
0
        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
                {
                });
            }
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }