Exemplo n.º 1
0
            public async Task <List <InfringementTop5DTO> > Handle(Data request, CancellationToken cancellationToken)
            {
                var listAll = await _driverInfringementRepository.GetAll();

                var infringements = listAll.GroupBy(i => i.InfringementId)
                                    .Select(group => new
                {
                    Infringement = group.Key,
                    Count        = group.Count()
                })
                                    .OrderBy(x => x.Count)
                                    .Take(5);

                var resultList = new List <InfringementTop5DTO>();

                foreach (var item in infringements)
                {
                    var list = new InfringementTop5DTO
                    {
                        Infringement = item.Infringement,
                        Count        = item.Count
                    };
                    resultList.Add(list);
                }
                ;

                return(resultList);
            }
Exemplo n.º 2
0
            public async Task <List <DriverInfringement> > Handle(InfringementList request, CancellationToken cancellationToken)
            {
                var infringements = await _driverInfringementRepository.GetAll();

                return(infringements);
            }