示例#1
0
        public BarcodeLookupQueryResult Handle(BarcodeLookupQuery query)
        {
            try
            {
                var eventTicketDetails = _eventTicketDetailRepository.GetRASVRideEventTicketDetails()
                                         .ToDictionary(k => k.Id);
                var matchSeatTicketDetails = _matchSeatTicketDetailRepository.GetByTransactionIdAndTicketDetailIds(query.TransactionId, eventTicketDetails.Keys)
                                             .ToList();
                if (matchSeatTicketDetails.Any())
                {
                    var transaction       = _transactionRepository.Get((long)matchSeatTicketDetails.First().TransactionId);
                    var currency          = _currencyTypeRepository.GetById(transaction.CurrencyId);
                    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 ticketCategories = _ticketCategoryRepository.GetByEventDetailIds(eventTicketDetails.Keys).ToDictionary(k =>k.Id);
                    var ticketCategories      = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => s.Value.TicketCategoryId)).ToDictionary(k => k.Id);
                    var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Keys).ToDictionary(k => k.EventTicketDetailId);

                    var barcodedetails = matchSeatTicketDetails.Select(mst =>
                    {
                        var eventTicketDetail = eventTicketDetails[mst.EventTicketDetailId];
                        var attributes        = eventTicketAttributes[eventTicketDetail.Id];
                        var value             = JsonConvert.DeserializeObject <TicketValue>(attributes.AdditionalInfo).value;

                        return(new BarcodeDetailsContainer
                        {
                            AltId = (System.Guid)mst.AltId,
                            BarcodeNumber = mst.BarcodeNumber,
                            CurrencyCode = currency.Code,
                            TicketCategoryId = eventTicketDetail.TicketCategoryId,
                            TicketCategory = ticketCategories[(int)eventTicketDetail.TicketCategoryId].Name,
                            Value = value,
                            Postalcode = postalcode,
                            IsConsumed = mst.IsConsumed,
                            ConsumedDateTime = mst.ConsumedDateTime,
                            TransactionUTC = transaction.CreatedUtc,
                        });
                    });

                    return(new BarcodeLookupQueryResult
                    {
                        BarcodeDetailsContainer = barcodedetails.ToList(),
                        IsValid = true
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            return(new BarcodeLookupQueryResult
            {
                BarcodeDetailsContainer = null,
                IsValid = false
            });
        }
示例#2
0
        public ResultCommand Handle(DeleteCurrencyTypeCommand command)
        {
            var result = new ResultCommand();

            var currencyType = _repository.GetById(command.Id);

            currencyType.Delete();

            result.AddNotifications(currencyType);

            if (result.Valid)
            {
                _repository.Update(currencyType);
            }

            return(result);
        }
示例#3
0
        public CurrencyTypeResult Handle(GetById query)
        {
            // TODO Colocar o automapper
            var result = new CurrencyTypeResult();

            var resulten = _repository
                           .GetById(query.Id);

            return(result);
        }
示例#4
0
        public ResultCommand Handle(CreateWalletCommand command)
        {
            var result = new ResultCommand();

            var client       = _clientRepository.GetById(command.ClientId);
            var currencyType = _currencyTypeRepository.GetById(command.CurrencyTypeId);

            var wallet = new Wallet(client, currencyType);

            result.AddNotifications(wallet);

            if (result.Valid)
            {
                _repository.Insert(wallet);
            }

            return(result);
        }
示例#5
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
            });
        }