Exemple #1
0
        public async Task <int> GenerateCountFromAdvancedCriteria(BenchmarkCriteriaVM criteria)
        {
            if (!ModelState.IsValid)
            {
                return(0);
            }

            return(await _financialDataService.SearchTrustCountByCriteriaAsync(criteria?.AdvancedCriteria));
        }
Exemple #2
0
        public async Task <int> GenerateCountFromAdvancedCriteria(BenchmarkCriteriaVM criteria, EstablishmentType estType, int?lacode, bool excludePartial = false)
        {
            if (!ModelState.IsValid)
            {
                return(0);
            }

            if (criteria.AdvancedCriteria == null)
            {
                criteria.AdvancedCriteria = new BenchmarkCriteria();
            }
            criteria.AdvancedCriteria.LocalAuthorityCode = lacode;
            var result = await _financialDataService.SearchSchoolsCountByCriteriaAsync(criteria.AdvancedCriteria, estType, excludePartial);

            return(result);
        }
        public async Task <int> GenerateCountFromManualCriteria(BenchmarkCriteriaVM criteria, EstablishmentType estType, int?lacode)
        {
            if (!ModelState.IsValid)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(new System.ApplicationException("Invalid criteria entered for advanced search!"));
                return(0);
            }

            if (criteria.AdvancedCriteria != null && !criteria.AdvancedCriteria.IsAllPropertiesNull())
            {
                criteria.AdvancedCriteria.LocalAuthorityCode = lacode;
                var result = await _financialDataService.SearchSchoolsCountByCriteriaAsync(criteria.AdvancedCriteria, estType);

                return(result);
            }
            return(0);
        }
Exemple #4
0
        public async Task <ActionResult> GenerateListFromAdvancedCriteria(BenchmarkCriteriaVM criteria, ComparisonType?comparison = null)
        {
            if (!ModelState.IsValid)
            {
                new TelemetryClient().TrackException(new ApplicationException("Invalid criteria entered for advanced search!" + criteria));
                throw new ApplicationException();
            }

            if (criteria.AdvancedCriteria != null && !criteria.AdvancedCriteria.IsAllPropertiesNull())
            {
                _trustBenchmarkListService.ClearTrustBenchmarkList();
                _trustBenchmarkListService.AddDefaultTrustToBenchmarkList();
                var trustDocs = await _financialDataService.SearchTrustsByCriteriaAsync(criteria.AdvancedCriteria);

                foreach (var doc in trustDocs)
                {
                    _trustBenchmarkListService.TryAddTrustToBenchmarkList(doc.CompanyNumber.GetValueOrDefault(), doc.TrustOrCompanyName);
                }
            }

            TempData["BenchmarkCriteria"] = criteria.AdvancedCriteria;
            TempData["ComparisonType"]    = comparison;
            return(Redirect("/BenchmarkCharts/Mats"));
        }
Exemple #5
0
        public async Task <ActionResult> OverwriteStrategy(long?urn, ComparisonType comparisonType, EstablishmentType estType, BenchmarkCriteriaVM criteria,
                                                           ComparisonArea areaType, int?lacode, string schoolName, int basketCount, bool excludePartial = false)
        {
            ViewBag.URN            = urn;
            ViewBag.HomeSchoolName = schoolName;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            ViewBag.AreaType       = areaType;
            ViewBag.LaCode         = lacode;
            ViewBag.ExcludePartial = excludePartial.ToString();

            var benchmarkList = _benchmarkBasketService.GetSchoolBenchmarkList();

            if (!ModelState.IsValid)
            {
                if (urn.HasValue)
                {
                    var benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.Value), benchmarkList);
                    var schoolsLatestFinancialDataModel = await _financialDataService.GetSchoolsLatestFinancialDataModelAsync(benchmarkSchool.Id, benchmarkSchool.EstablishmentType);

                    benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel> {
                        schoolsLatestFinancialDataModel
                    };
                    var schoolCharsVM = new SchoolCharacteristicsViewModel(benchmarkSchool, benchmarkList, new BenchmarkCriteria());
                    schoolCharsVM.ErrorMessage = "Validation Error";
                    return(View("AdvancedCharacteristics", schoolCharsVM));
                }
                else
                {
                    var schoolCharsVM = new SchoolCharacteristicsViewModel(new SchoolViewModelWithNoDefaultSchool(), benchmarkList, new BenchmarkCriteria());
                    schoolCharsVM.ErrorMessage = "Validation Error";
                    return(View("AdvancedCharacteristics", schoolCharsVM));
                }
            }

            if ((benchmarkList.BenchmarkSchools.Count > 1) ||
                (benchmarkList.BenchmarkSchools.Count == 1 && benchmarkList.BenchmarkSchools[0].Urn != benchmarkList.HomeSchoolUrn))
            {
                criteria.ComparisonList = benchmarkList;
                if (criteria.AdvancedCriteria == null)
                {
                    criteria.AdvancedCriteria = new BenchmarkCriteria();
                }
                if (benchmarkList.BenchmarkSchools.Count + basketCount > ComparisonListLimit.LIMIT)
                {
                    return(View("OverwriteReplace", criteria));
                }
                else
                {
                    return(View(criteria));
                }
            }
            else
            {
                TempData["URN"] = urn;
                TempData["BenchmarkCriteria"] = criteria.AdvancedCriteria;
                TempData["EstType"]           = estType;
                TempData["AreaType"]          = areaType;
                TempData["LaCode"]            = lacode;
                TempData["ExcludePartial"]    = excludePartial;

                return(RedirectToAction("GenerateNewFromAdvancedCriteria", "BenchmarkCharts"));
            }
        }
        /// <summary>
        /// Step 4 - Advanced
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <param name="criteria"></param>
        /// <param name="areaType"></param>
        /// <param name="lacode"></param>
        /// <param name="schoolName"></param>
        /// <returns></returns>
        public ActionResult OverwriteStrategy(string urn, ComparisonType comparisonType, EstablishmentType estType, BenchmarkCriteriaVM criteria, ComparisonArea areaType, int?lacode, string schoolName)
        {
            ViewBag.URN            = urn;
            ViewBag.HomeSchoolName = schoolName;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            ViewBag.AreaType       = areaType;
            ViewBag.LaCode         = lacode;

            var benchmarkList = base.ExtractSchoolComparisonListFromCookie();

            if (!ModelState.IsValid)
            {
                var benchmarkSchool = new SchoolViewModel(_contextDataService.GetSchoolByUrn(urn), benchmarkList);
                var latestYear      = _financialDataService.GetLatestDataYearPerSchoolType(benchmarkSchool.FinancialType);
                var term            = FormatHelpers.FinancialTermFormatAcademies(latestYear);
                var document        = _financialDataService.GetSchoolDataDocument(urn, term, benchmarkSchool.FinancialType);
                benchmarkSchool.HistoricalSchoolFinancialDataModels = new List <SchoolFinancialDataModel> {
                    new SchoolFinancialDataModel(urn, term, document, benchmarkSchool.FinancialType)
                };
                var schoolCharsVM = new SchoolCharacteristicsViewModel(benchmarkSchool, benchmarkList, new BenchmarkCriteria());
                schoolCharsVM.ErrorMessage = "Validation Error";
                return(View("AdvancedCharacteristics", schoolCharsVM));
            }

            if ((benchmarkList.BenchmarkSchools.Count > 1) ||
                (benchmarkList.BenchmarkSchools.Count == 1 && benchmarkList.BenchmarkSchools[0].Urn != benchmarkList.HomeSchoolUrn))
            {
                criteria.ComparisonList = benchmarkList;
                return(View(criteria));
            }
            else
            {
                TempData["URN"] = urn;
                TempData["BenchmarkCriteria"] = criteria.AdvancedCriteria;
                TempData["EstType"]           = estType;
                TempData["AreaType"]          = areaType;
                TempData["LaCode"]            = lacode;

                return(RedirectToAction("GenerateNewFromAdvancedCriteria", "BenchmarkCharts"));
            }
        }