BAL.Manager.UserManager.GetDriversWithOrdersLastMonth C# (CSharp) Метод

GetDriversWithOrdersLastMonth() публичный Метод

public GetDriversWithOrdersLastMonth ( ) : IEnumerable
Результат IEnumerable
        public IEnumerable<DriverWithOrdersDTO> GetDriversWithOrdersLastMonth()
        {
            var drivers = Mapper.Map<List<UserDTO>>(uOW.UserRepo.All.Where(u => u.RoleId == (int)AvailableRoles.Driver));
            var driversWithOrders = new List<DriverWithOrdersDTO>();
            foreach (var driver in drivers)
            {
                var driverWithOrders = new DriverWithOrdersDTO();
                driverWithOrders.Driver = driver;
                driverWithOrders.OrdersCount = uOW.OrderExRepo.All.Where(o => o.DriverId == driver.Id
                    && o.OrderTime.Year == DateTime.Now.Year
                    && o.OrderTime.Month == DateTime.Now.Month).Count();
                var person = Mapper.Map<PersonDTO>(uOW.PersonRepo.All.Where(p => p.UserId == driver.Id).FirstOrDefault());
                if (person != null)
                {
                    if (person.ImageName != null)
                        driverWithOrders.Image = person.ImageName;
                    else
                        driverWithOrders.Image = "item_0_profile.jpg";
                    driverWithOrders.Name = person.FullName;
                }
                else
                    driverWithOrders.Image = "item_0_profile.jpg";
                driversWithOrders.Add(driverWithOrders);
            }
            driversWithOrders.Sort(delegate (DriverWithOrdersDTO x, DriverWithOrdersDTO y)
            {
                return y.OrdersCount.CompareTo(x.OrdersCount);
            });
            return driversWithOrders;
        }