Пример #1
0
 protected override async Task Handle(SaveOrderCommand command)
 {
     try
     {
         //check if there is discount component available for that variant
         var citySightSeeingTicketTypeDetails = _citySightSeeingTicketTypeDetailRepository.GetAllByTicketId(command.TicketId).Where(s => s.UnitDiscount != "0.00").ToList();
         if (citySightSeeingTicketTypeDetails.Count() > 0)
         {
             var     trasactionDetail      = _transactionDetailRepository.GetByTransactionId(command.TransactionId);
             var     eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketAttributeIds(trasactionDetail.Select(s => s.EventTicketAttributeId));
             var     eventTicketDetails    = _eventTicketDetailRepository.GetAllByEventTicketDetailIds(eventTicketAttributes.Select(s => s.EventTicketDetailId));
             var     ticketCategories      = _ticketCategoryRepository.GetAllTicketCategory(eventTicketDetails.Select(s => s.TicketCategoryId));
             decimal totalDiscountAmount   = 0;
             foreach (var currentCitySightSeeingTicketType in citySightSeeingTicketTypeDetails)
             {
                 var currentTicketCat            = ticketCategories.Where(s => s.Name == currentCitySightSeeingTicketType.TicketType).FirstOrDefault();
                 var currentEventTicketDetail    = eventTicketDetails.Where(s => s.TicketCategoryId == currentTicketCat.Id).FirstOrDefault();
                 var currentEventTicketAttribute = eventTicketAttributes.Where(s => s.EventTicketDetailId == currentEventTicketDetail.Id).FirstOrDefault();
                 var currentTransactionDetail    = trasactionDetail.Where(s => s.EventTicketAttributeId == currentEventTicketAttribute.Id).FirstOrDefault();
                 currentTransactionDetail.DiscountAmount = (Convert.ToInt16(currentCitySightSeeingTicketType.UnitDiscount) * currentTransactionDetail.TotalTickets);
                 _transactionDetailRepository.Save(currentTransactionDetail);
                 totalDiscountAmount = totalDiscountAmount + (Convert.ToInt16(currentCitySightSeeingTicketType.UnitDiscount) * currentTransactionDetail.TotalTickets);
             }
             var transaction = _transactionRepository.Get(command.TransactionId);
             transaction.DiscountAmount  = totalDiscountAmount;
             transaction.NetTicketAmount = transaction.GrossTicketAmount - totalDiscountAmount;
             _transactionRepository.Save(transaction);
         }
         var citySightSeeingTransactionData = new CitySightSeeingTransactionDetail
         {
             AltId        = Guid.NewGuid(),
             FromDateTime = command.FromTime,
             EndDateTime  = command.EndTime,
             HasTimeSlot  = true,
             ReservationDistributorReference = command.Distributor_reference,
             TicketId              = command.TicketId,
             TransactionId         = command.TransactionId,
             ReservationValidUntil = command.Reservation_valid_until.ToString(),
             ReservationReference  = command.Reservation_reference,
             TimeSlot              = command.TimeSlot,
             ModifiedBy            = command.ModifiedBy
         };
         var citySightSeeingTransaction = _citySightSeeingTransactionDetailRepository.Save(citySightSeeingTransactionData);
     }
     catch (Exception e)
     {
         _logger.Log(LogCategory.Error, new Exception("Failed to Disable Event HOHO Data", e));
     }
 }
Пример #2
0
        public GetDetailQueryResult Handle(GetDetailQuery query)
        {
            try
            {
                var transaction = _transactionRepository.GetSuccessfulTransactionDetails(query.TransactionId);
                if (transaction == null)
                {
                    return(new GetDetailQueryResult());
                }

                var transactionDetails    = _transactionDetailsRepository.GetByTransactionId(transaction.Id).ToList();
                var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketAttributeIds(transactionDetails.Select(s => s.EventTicketAttributeId).Distinct());
                var eventTicketDetails    = _eventTicketDetailRepository.GetByIds(eventTicketAttributes.Select(s => s.EventTicketDetailId).Distinct());
                var eventDetails          = _eventDetailRepository.GetByEventDetailIds(eventTicketDetails.Select(s => s.EventDetailId).Distinct());
                var events               = _eventRepository.GetByAllEventIds(eventDetails.Select(s => s.EventId).Distinct());
                var filteredEvents       = events.Where(s => s.CreatedBy == query.UserAltId);
                var filteredEventDetails = eventDetails
                                           .Where(x => filteredEvents.Any(y => y.Id == x.EventId));
                var filteredEventTicketDetails = eventTicketDetails
                                                 .Where(x => filteredEventDetails.Any(y => y.Id == x.EventDetailId));
                var ticketCategories             = _ticketCategoryRepository.GetAllTicketCategory(filteredEventTicketDetails.Select(s => s.TicketCategoryId));
                var filteredEventTicktAttributes = eventTicketAttributes
                                                   .Where(x => filteredEventTicketDetails.Any(y => y.Id == x.EventTicketDetailId));
                var filteredTransactionDetail = transactionDetails
                                                .Where(x => filteredEventTicktAttributes.Any(y => y.Id == x.EventTicketAttributeId));
                return(new GetDetailQueryResult
                {
                    EventDetail = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventDetail> >(filteredEventDetails),
                    EventTicketAttribute = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventTicketAttribute> >(filteredEventTicktAttributes),
                    TicketCategory = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TicketCategory> >(ticketCategories),
                    EventTicketDetail = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventTicketDetail> >(eventTicketDetails),
                    TransactionDetail = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TransactionDetail> >(filteredTransactionDetail)
                });
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, new Exception("Failed to get Details", e));
                return(new GetDetailQueryResult());
            }
        }
Пример #3
0
        public TicketCategoryDetailQueryResult Handle(TicketCategoryDetailQuery query)
        {
            try
            {
                var ticketCategoryDetails    = _ticketCategoryDetailRepository.GetAll();
                var ticketCategoryDetailData = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TicketCategoryDetail> >(ticketCategoryDetails);

                var ticketCategoryies  = _ticketCategoryRepository.GetAllTicketCategory(ticketCategoryDetails.Select(s => (long)s.TicketCategoryId));
                var ticketCategoryData = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TicketCategory> >(ticketCategoryies);

                return(new TicketCategoryDetailQueryResult
                {
                    TicketCategoryDetails = ticketCategoryDetailData,
                    TicketCategories = ticketCategoryData
                });
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
                return(new TicketCategoryDetailQueryResult {
                });
            }
        }