public async Task <int> RefreshAllCommunityInfo() { SeashellContext context = new SeashellContext(); List <AdministrativeDistrict> districts = context.AdministrativeDistrict.ToList(); List <Community> communities = new List <Community>(); foreach (AdministrativeDistrict district in districts) { List <Community> communitiesByDistrict = await ReadAllCommunities(district.CommunityMainPageURL); communities = communities.Concat(communitiesByDistrict).ToList(); } communities = await ReadCommunityDetailInfo(communities); CommunityRepository repo = new CommunityRepository(context); repo.AddOrUpdate(communities); repo.Save(); return(communities.Count()); }
public async Task <int> GetHistoryInfoForAllCommunities() { SeashellContext context = new SeashellContext(); List <Community> communities = context.Communities.ToList(); communities = await ReadCommunityDetailInfo(communities); CommunityRepository repo = new CommunityRepository(context); repo.AddOrUpdate(communities); repo.Save(); return(communities.Count()); }