public static IArea NewArea(IAreasReader areasReader, string areaCode) { if (areaCode == null) { throw new FingertipsException("Area code was null"); } // Category areas if (CategoryArea.IsCategoryAreaCode(areaCode)) { var categoryArea = new CategoryArea(areaCode); var category = areasReader.GetCategory(categoryArea.CategoryTypeId, categoryArea.CategoryId); categoryArea.SetNames(category); return categoryArea; } // Nearest neighbour if (NearestNeighbourArea.IsNearestNeighbourAreaCode(areaCode)) { var nearestNeighboursArea = new NearestNeighbourArea(areaCode); nearestNeighboursArea.Neighbours = areasReader.GetNearestNeighbours( nearestNeighboursArea.AreaCodeOfAreaWithNeighbours, nearestNeighboursArea.NeighbourTypeId); return nearestNeighboursArea; } // Standard area return areasReader.GetAreaFromCode(areaCode); }
public ChildAreaListForCategoryAreaBuilder(IAreasReader reader, CategoryArea parentArea, int childAreaType) { var areaCodes = reader .GetCategorisedAreasForOneCategory(AreaTypeIds.Country, childAreaType, parentArea.CategoryTypeId, parentArea.CategoryId) .Select(x => x.AreaCode); var areaListBuilder = new AreaListProvider(reader); areaListBuilder.CreateAreaListFromAreaCodes(areaCodes); ChildAreas = areaListBuilder.Areas.OrderBy(x=> x.Name).ToList(); }
public void TestCategoryAreaCount() { // Arrange var parentArea = new CategoryArea(AreaCodes.DeprivationDecile_Utla3); _areasReader.Setup(x => x.GetChildAreaCount(parentArea, ChildAreaTypeId)) .Returns(2); // Act & Assert Assert.AreEqual(2, GetCount(parentArea)); _areasReader.VerifyAll(); }
public virtual IList<CoreDataSet> GetCoreDataListForChildrenOfCategoryArea(Grouping grouping, TimePeriod period, CategoryArea categoryArea) { IQuery q = CurrentSession.CreateQuery(GetCoreDataListForChildrenOfCategoryAreaQueryString); q.SetParameter("categoryTypeId", categoryArea.CategoryTypeId); q.SetParameter("categoryId", categoryArea.CategoryId); q.SetParameter("childAreaTypeId", grouping.AreaTypeId); q.SetParameter("parentAreaTypeId", categoryArea.ParentAreaTypeId); SetTimePeriodParameters(q, period); SetGroupingParameters(q, grouping); return q.List<CoreDataSet>(); }
public virtual double GetGpDeprivationDecileDataValue(Grouping grouping, TimePeriod period, CategoryArea categoryArea) { // Age ID currently ignored SqlCommand cmd = new SqlCommand(string.Format(SqlGetPracticeAggregateDataValueForCategorisedAreas, grouping.IndicatorId, grouping.SexId, period.Year, period.YearRange, period.Quarter, period.Month, AreaTypeIds.GpPractice, categoryArea.CategoryId, categoryArea.CategoryTypeId, grouping.AgeId), GetConnection()); object o = ReadObject(cmd); if (o == null || o is DBNull) { return ValueData.NullValue; } return (double)o; }
public CategoryAreaCoreDataSetProvider(CategoryArea area, IGroupDataReader groupDataReader) : base(area) { this.groupDataReader = groupDataReader; }
/// <summary> /// Total number of areas of a given area type. /// </summary> public int GetChildAreaCount(CategoryArea categoryArea, int childAreaTypeId) { var q = CurrentSession.CreateQuery("select count (a) from CategorisedArea a " + "where a.CategoryTypeId = :categoryTypeId and a.CategoryId = :categoryId and a.ChildAreaTypeId = :childAreaTypeId and a.ParentAreaTypeId = : parentAreaTypeId"); q.SetParameter("categoryTypeId", categoryArea.CategoryTypeId); q.SetParameter("categoryId", categoryArea.CategoryId); q.SetParameter("childAreaTypeId", childAreaTypeId); q.SetParameter("parentAreaTypeId", categoryArea.ParentAreaTypeId); return Convert.ToInt32(q.UniqueResult<long>()); }
public void TestGetChildAreaCountForCategoryArea() { IAreasReader reader = ReaderFactory.GetAreasReader(); var area = new CategoryArea(AreaCodes.DeprivationDecile_Utla3); int count = reader.GetChildAreaCount(area, AreaTypeIds.CountyAndUnitaryAuthority); Assert.IsTrue(count > 10 && count < 20); }
public GpDeprivationDecileCoreDataSetProvider(CategoryArea categoryArea, PracticeDataAccess practiceDataAccess) : base(categoryArea) { this.categoryArea = categoryArea; this.practiceDataAccess = practiceDataAccess; }
private int GetCount(CategoryArea parentArea) { var count = GetCounter().GetChildAreasCount(parentArea, ChildAreaTypeId); return count; }