public IEnumerable <VehicleReport> GetByNumberOfSales() { IEnumerable <Sale> sales = _salesProvider.GetAll(); var salesPerVehicle = sales.GroupBy(s => s.Vehicle).Select(group => new { Count = group.Count(), Amount = group.Sum(s => s.Price), Vehicle = group.Key }) .OrderByDescending(g => g.Count); var result = new List <VehicleReport>(); foreach (var item in salesPerVehicle) { result.Add(new VehicleReport() { Count = item.Count, SalesAmount = item.Amount, Vehicle = item.Vehicle, }); } return(result); }
public IEnumerable <Sale> Get() { return(_repository.GetAll()); }
public IEnumerable <Sale> GetAll() { return(_provider.GetAll().OrderByDescending(s => s.Date)); }