public static IAreaType New(IAreasReader areasReader, int parentAreaTypeId) { if (CategoryAreaType.IsCategoryAreaTypeId(parentAreaTypeId)) { var categoryTypeId = CategoryAreaType.GetCategoryTypeIdFromAreaTypeId(parentAreaTypeId); var categoryType = areasReader.GetCategoryType(categoryTypeId); return CategoryAreaType.New(categoryType); } return areasReader.GetAreaType(parentAreaTypeId); }
public static IAreaType New(IAreasReader areasReader, ParentAreaGroup parentAreaGroup) { if (parentAreaGroup.ParentAreaTypeId.HasValue) { return areasReader.GetAreaType(parentAreaGroup.ParentAreaTypeId.Value); } if (parentAreaGroup.CategoryTypeId.HasValue) { var categoryType = areasReader.GetCategoryType(parentAreaGroup.CategoryTypeId.Value); return CategoryAreaType.New(categoryType); } throw new FingertipsException("Could not create an area type for Id=" + parentAreaGroup.Id); }
private void InitAreaCodeToNameLookUp(IAreasReader areasReader, IList<int> areaTypeIds) { areaCodeToName = new Dictionary<string, string>(); areaCodeToTypeName = new Dictionary<string, string>(); foreach (var areaTypeId in areaTypeIds) { var areaType = areasReader.GetAreaType(areaTypeId); var areas = areasReader.GetAreasByAreaTypeId(areaTypeId); foreach (var area in areas) { var areaCode = area.Code; if (areaCodeToName.ContainsKey(areaCode) == false) { areaCodeToTypeName.Add(areaCode, areaType.ShortName); areaCodeToName.Add(areaCode, area.Name); } } } }