public DirectPropertyGeoModel GetGeoInfo_Client() { Client client = edisRepo.GetClientSync(User.Identity.GetUserId(), DateTime.Now); ClientGroup clientGroup = edisRepo.GetClientGroupSync(client.ClientGroupId, DateTime.Now); if (clientGroup.MainClientId == client.Id) { List<GroupAccount> groupAccounts = edisRepo.GetAccountsForClientGroupSync(clientGroup.ClientGroupNumber, DateTime.Now); List<ClientAccount> clientAccounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now); List<DirectPropertyGeoItem> dataList = new List<DirectPropertyGeoItem>(); List<DirectProperty> properties = new List<DirectProperty>(); foreach (var account in groupAccounts) { properties.AddRange(account.GetAssetsSync().OfType<DirectProperty>().ToList()); } foreach (var account in clientAccounts) { properties.AddRange(account.GetAssetsSync().OfType<DirectProperty>().ToList()); } foreach (var property in properties) { dataList.Add(new DirectPropertyGeoItem { id = property.Id, address = property.FullAddress, latitude = property.Latitude == null ? 0 : (double)property.Latitude, longitude = property.Longitude == null ? 0 : (double)property.Longitude, country = property.Country, state = property.State, type = property.PropertyType, value = property.GetTotalMarketValue() }); } DirectPropertyGeoModel model = new DirectPropertyGeoModel { data = dataList }; return model; } else { List<ClientAccount> accounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now); List<DirectPropertyGeoItem> dataList = new List<DirectPropertyGeoItem>(); List<DirectProperty> properties = new List<DirectProperty>(); foreach (var account in accounts) { properties.AddRange(account.GetAssetsSync().OfType<DirectProperty>().ToList()); } foreach (var property in properties) { dataList.Add(new DirectPropertyGeoItem { id = property.Id, address = property.FullAddress, latitude = property.Latitude == null ? 0 : (double)property.Latitude, longitude = property.Longitude == null ? 0 : (double)property.Longitude, country = property.Country, state = property.State, type = property.PropertyType, value = property.GetTotalMarketValue() }); } DirectPropertyGeoModel model = new DirectPropertyGeoModel { data = dataList }; return model; } }
public DirectPropertyGeoModel GeneratePropertyGeoModel(List<AssetBase> assets) { List<DirectPropertyGeoItem> dataList = new List<DirectPropertyGeoItem>(); foreach (var property in assets.OfType<DirectProperty>().ToList()) { dataList.Add(new DirectPropertyGeoItem { id = property.Id, address = property.FullAddress, latitude = property.Latitude == null ? 0 : (double)property.Latitude, longitude = property.Longitude == null ? 0 : (double)property.Longitude, country = property.Country, state = property.State, type = property.PropertyType, value = property.GetTotalMarketValue() }); } DirectPropertyGeoModel model = new DirectPropertyGeoModel { data = dataList }; return model; }