示例#1
0
        public Task <QueryResponse <List <SimpleCoinsViewModel> > > Handle(GetAllCoinsQuery request, CancellationToken cancellationToken)
        {
            QueryResponse <List <SimpleCoinsViewModel> > response;

            try
            {
                var coins      = _coinRepository.Filter(x => x.IsActive);
                var result     = _mapper.Map <List <SimpleCoinsViewModel> >(coins);
                var totalCount = result.Count;
                response = new QueryResponse <List <SimpleCoinsViewModel> >(result, totalCount);
            }
            catch (Exception e)
            {
                var errors = new List <string> {
                    e.Message
                };
                if (e.InnerException != null)
                {
                    errors.Add(e.InnerException.Message);
                }


                response = new
                           QueryResponse <List <SimpleCoinsViewModel> >(null, 0)
                {
                    ErrorMessage = ExceptionHandler.GetError(e)
                };
            }

            return(Task.FromResult(response));
        }