public FacultyStaffSummaryModel GetDegreePeopleCount(int? establishmentId, int? placeId) { var model = new FacultyStaffSummaryModel(); var tenancy = Request.Tenancy(); Establishment establishment = null; if (establishmentId.HasValue && (establishmentId.Value != 0)) { establishment = _queryProcessor.Execute(new EstablishmentById(establishmentId.Value)); } else { if (tenancy.TenantId.HasValue) { establishment = _queryProcessor.Execute(new EstablishmentById(tenancy.TenantId.Value)); } else if (!String.IsNullOrEmpty(tenancy.StyleDomain) && !"default".Equals(tenancy.StyleDomain)) { establishment = _queryProcessor.Execute(new EstablishmentByEmail(tenancy.StyleDomain)); } } if (establishment != null) { var settings = _queryProcessor.Execute(new EmployeeModuleSettingsByEstablishmentId(establishment.RevisionId)); DateTime toDateUtc = new DateTime(DateTime.UtcNow.Year + 1, 1, 1); DateTime fromDateUtc = (settings != null) && (settings.ReportsDefaultYearRange.HasValue) ? toDateUtc.AddYears(-(settings.ReportsDefaultYearRange.Value + 1)) : new DateTime(DateTime.MinValue.Year, 1, 1); if (placeId.HasValue) { int[] placeIds = GetPlaceIds(placeId.Value); model.PlaceId = placeIds[0]; //model.Count = // _queryProcessor.Execute(new PeopleWithDegreesCountByPlaceIdsEstablishmentId(placeIds, // establishment.RevisionId, // fromDateUtc, // toDateUtc, // false /* (noUndated) included undated */)); model.CountOfPlaces = 1; model.PlaceCounts = null; } else { model.PlaceId = null; //model.Count = // _queryProcessor.Execute(new PeopleWithDegreesCountByEstablishmentId(establishment.RevisionId, // fromDateUtc, // toDateUtc, // false /* (noUndated) included undated */)); model.CountOfPlaces = 0; model.PlaceCounts = null; } } return model; }
//[CacheHttpGet(Duration = 3600)] public FacultyStaffSummaryModel GetPeopleCount(int? establishmentId, int? placeId) { var model = new FacultyStaffSummaryModel(); var tenancy = Request.Tenancy(); Establishment establishment = null; if (establishmentId.HasValue && (establishmentId.Value != 0)) { establishment = _queryProcessor.Execute(new EstablishmentById(establishmentId.Value)); } else { if (tenancy.TenantId.HasValue) { establishment = _queryProcessor.Execute(new EstablishmentById(tenancy.TenantId.Value)); } else if (!String.IsNullOrEmpty(tenancy.StyleDomain) && !"default".Equals(tenancy.StyleDomain)) { establishment = _queryProcessor.Execute(new EstablishmentByEmail(tenancy.StyleDomain)); } } //if (establishment != null) //{ // if (placeId.HasValue) // { // int[] placeIds = GetPlaceIds(placeId.Value); // var view = new ActivityPlacePeopleCountView(_queryProcessor, _entities, // establishment.RevisionId, // placeIds); // model.PlaceId = placeIds[0]; // model.Count = view.Count; // model.CountOfPlaces = 1; // model.PlaceCounts = null; // foreach (var type in view.TypeCounts) // { // model.TypeCounts.Add(new FacultyStaffTypeCountModel // { // TypeId = type.TypeId, // Type = type.Type, // Count = type.Count // }); // } // model.TypeCounts = model.TypeCounts.OrderBy(t => t.Rank).ToList(); // } // else // { // //var view = new ActivityGlobalPeopleCountView(_queryProcessor, _entities, // // establishment.RevisionId); // //try // //{ // // ActivityGlobalPeopleCountView view = // // _activityProjector.BeginReadPeopleCountsView(establishment.RevisionId); // try // { // GlobalPeopleCountView view = // _activityProjector.BeginReadPeopleCountsView(establishment.RevisionId); // if (view != null) // { // model.Count = view.Count; // model.CountOfPlaces = view.CountOfPlaces; // foreach (var placeCount in view.PlaceCounts) // { // model.PlaceCounts.Add(new FacultyStaffPlaceCountModel // { // PlaceId = placeCount.PlaceId, // CountryCode = placeCount.CountryCode, // OfficialName = placeCount.OfficialName, // Count = placeCount.Count, // Lat = placeCount.Lat, // Lng = placeCount.Lng // }); // } // foreach (var type in view.TypeCounts) // { // model.TypeCounts.Add(new FacultyStaffTypeCountModel // { // TypeId = type.TypeId, // Type = type.Type, // Count = type.Count // }); // } // model.TypeCounts = model.TypeCounts.OrderBy(t => t.Rank).ToList(); // } // } // finally // { // _activityProjector.EndReadPeopleCountsView(); // } // } //} return model; }