public CategoryAreaDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheet, ProfileDataWriter profileDataWriter, CategoryAreaType categoryAreaType) : base(areasReader, groupDataReader, worksheet, profileDataWriter) { _categoryAreaTypeId = categoryAreaType.CategoryTypeId; categories = areasReader.GetCategories(_categoryAreaTypeId); subnationalCategoryIdToCategoryAreaMap = categories .ToDictionary<Category, int, IArea>( category => category.Id, category => CategoryArea.New(category) ); }
private void BuildCategoryAreaMap(CategoryAreaType categoryAreaType, ParentArea parentArea) { var categories = _areasReader.GetCategories(categoryAreaType.CategoryTypeId); var subnationalCategoryIdToCategoryAreaMap = categories .ToDictionary<Category, int, IArea>( category => category.Id, CategoryArea.New ); foreach ( var categorisedArea in _areasReader.GetCategorisedAreasForAllCategories(AreaTypeIds.Country, parentArea.ChildAreaTypeId, categoryAreaType.CategoryTypeId)) { var area = new Area { Code = categorisedArea.CategoryId.ToString(), Name = subnationalCategoryIdToCategoryAreaMap[categorisedArea.CategoryId].Name }; _areaCodeToParentMap.Add(categorisedArea.AreaCode, area); } }