Example #1
0
        public async Task <TicketViewModel> Handle(TicketQuery message)
        {
            if (!Guid.TryParse(message?.Id, out Guid id))
            {
                throw new ArgumentException($"Not a valid ticket id: {message?.Id}", nameof(message));
            }

            var ticketId = id.ToString();
            var ticket   = _repository.Find(ticketId);
            var events   = _eventRepository.Find(ticketId);

            await Task.WhenAll(ticket, events);

            var ticketVM = _mapper.Map <TicketViewModel>(ticket.Result);

            ticketVM.Events = _mapper.Map <List <TicketEventViewModel> >(events.Result);

            return(ticketVM);
        }
Example #2
0
        protected override async Task <List <TicketEventViewModel> > HandleCore(TicketEventsQuery message)
        {
            var ticketEvents = await _repository.Find(message.TicketId);

            return(_mapper.Map <List <TicketEventViewModel> >(ticketEvents));
        }