List <CityViewModel> CreateCities(HashSet <Address> addresses, Period period = Period.Lifetime)
        {
            var newCities = new List <CityViewModel>();

            foreach (var city in addresses.Select(a => CityViewModel.Create(a, UnitOfWork)))
            {
                city.Sales = QueriesHelper.GetSaleMapItemsByCustomerAndCity(UnitOfWork.OrderItems, PrimaryKey, city.Address.City, period).GroupBy(mi => mi.Product).Select(gr => new SalesViewModel(gr.Key.Name, gr.CustomSum(mi => mi.Total)));
                string address = city.Address.City;
                if (!newCities.Any(c => c.Address.City == address))
                {
                    newCities.Add(city);
                }
            }
            return(newCities);
        }
Exemple #2
0
 public IEnumerable <DevAV.MapItem> GetSalesByCity(string city, Period period = Period.Lifetime)
 {
     return(QueriesHelper.GetSaleMapItemsByCustomerAndCity(UnitOfWork.OrderItems, Entity.Id, city, period));
 }
 protected override IEnumerable <SalesViewModel> GetActualStatistics(IDevAVDbUnitOfWork unitOfWork)
 {
     return(QueriesHelper.GetSaleMapItemsByCustomerAndCity(unitOfWork.OrderItems, EntityId, SelectedAddress.Address.City, FilterType).GroupBy(mi => mi.Product).Select(gr => new SalesViewModel(gr.Key.Name, gr.CustomSum(mi => mi.Total))));
 }