Exemplo n.º 1
0
        /// <summary>
        /// Step 1 - Advanced
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <returns></returns>
        public async Task <ViewResult> SelectSchoolType(long?urn, long?fuid, ComparisonType comparisonType, EstablishmentType?estType, int?basketSize)
        {
            ViewBag.URN            = urn;
            ViewBag.Fuid           = fuid;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            ViewBag.BasketSize     = basketSize;

            if (fuid.HasValue)
            {
                var benchmarkSchool = new FederationViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(fuid.Value), _benchmarkBasketService.GetSchoolBenchmarkList());
                _benchmarkBasketService.SetFederationAsDefault(benchmarkSchool);
                return(View("SelectSchoolType", benchmarkSchool));
            }
            else if (urn.HasValue)
            {
                var benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.Value), _benchmarkBasketService.GetSchoolBenchmarkList());

                return(View("SelectSchoolType", benchmarkSchool));
            }
            else
            {
                _benchmarkBasketService.UnsetDefaultSchool();
                return(View("SelectSchoolType", new SchoolViewModelWithNoDefaultSchool()));
            }
        }
Exemplo n.º 2
0
 public void TryAddFederationToBenchmarkList(FederationViewModel fedVM)
 {
     try
     {
         AddFederationToBenchmarkList(fedVM);
     }
     catch (ApplicationException) { }//ignore duplicate add
 }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            var comparisonList = _benchmarkBasketService.GetSchoolBenchmarkList();

            var benchmarkSchoolDataObjects = await _contextDataService.GetMultipleSchoolDataObjectsByUrnsAsync(comparisonList.BenchmarkSchools.Select(b => long.Parse(b.Urn)).ToList());

            comparisonList.BenchmarkSchools = new List <BenchmarkSchoolModel>();

            if (benchmarkSchoolDataObjects != null)
            {
                foreach (var benchmarkSchoolDataObject in benchmarkSchoolDataObjects)
                {
                    BenchmarkSchoolModel benchmarkSchool;

                    if (benchmarkSchoolDataObject.IsFederation)
                    {
                        var federation         = new FederationViewModel(benchmarkSchoolDataObject);
                        var financialDataModel = await _financialDataService.GetSchoolsLatestFinancialDataModelAsync(federation.Id, federation.EstablishmentType);

                        benchmarkSchool = new BenchmarkSchoolModel(federation)
                        {
                            IsReturnsComplete    = financialDataModel.IsReturnsComplete,
                            WorkforceDataPresent = financialDataModel.WorkforceDataPresent
                        };
                    }
                    else
                    {
                        var school             = new SchoolViewModel(benchmarkSchoolDataObject);
                        var financialDataModel = await _financialDataService.GetSchoolsLatestFinancialDataModelAsync(school.Id, school.EstablishmentType);

                        benchmarkSchool = new BenchmarkSchoolModel(school)
                        {
                            Address              = school.Address,
                            IsReturnsComplete    = financialDataModel.IsReturnsComplete,
                            WorkforceDataPresent = financialDataModel.WorkforceDataPresent
                        };
                    }

                    comparisonList.BenchmarkSchools.Add(benchmarkSchool);
                }
            }

            comparisonList.BenchmarkSchools = comparisonList.BenchmarkSchools.OrderBy(s => SanitizeSchoolName(s.Name)).ToList();

            return(View(comparisonList));
        }
Exemplo n.º 4
0
        public async Task AddSchoolToBenchmarkListAsync(long urn)
        {
            var contextData = await _contextDataService.GetSchoolDataObjectByUrnAsync(urn);

            if (contextData != null)
            {
                if (contextData.IsFederation)
                {
                    var benchmarkFederation = new FederationViewModel(contextData, null);
                    AddFederationToBenchmarkList(benchmarkFederation);
                }
                else
                {
                    var benchmarkSchool = new SchoolViewModel(contextData, null);
                    AddSchoolToBenchmarkList(benchmarkSchool);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Step 3 - Simple
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="fuid"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <param name="simpleCriteria"></param>
        /// <returns></returns>
        public async Task <ActionResult> SimpleCharacteristics(long?urn, long?fuid, ComparisonType comparisonType, EstablishmentType?estType, SimpleCriteria SimpleCriteria)
        {
            if (estType.HasValue)
            {
                ViewBag.URN            = urn;
                ViewBag.Fuid           = fuid;
                ViewBag.ComparisonType = comparisonType;
                ViewBag.EstType        = estType;

                EstablishmentViewModelBase benchmarkSchool;

                if (fuid.HasValue)
                {
                    benchmarkSchool = new FederationViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(fuid.Value), _benchmarkBasketService.GetSchoolBenchmarkList());
                }
                else
                {
                    benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.GetValueOrDefault()), _benchmarkBasketService.GetSchoolBenchmarkList());
                }

                var schoolCharsVM = new SimpleCharacteristicsViewModel(benchmarkSchool, SimpleCriteria);
                return(View(schoolCharsVM));
            }
            else
            {
                ViewBag.URN            = urn;
                ViewBag.Fuid           = fuid;
                ViewBag.ComparisonType = comparisonType;

                EstablishmentViewModelBase benchmarkSchool;
                if (fuid.HasValue)
                {
                    benchmarkSchool = new FederationViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(fuid.Value), _benchmarkBasketService.GetSchoolBenchmarkList());
                }
                else
                {
                    benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.GetValueOrDefault()), _benchmarkBasketService.GetSchoolBenchmarkList());
                }

                benchmarkSchool.ErrorMessage = ErrorMessages.SelectSchoolType;

                return(View("SelectSchoolType", benchmarkSchool));
            }
        }
Exemplo n.º 6
0
        public IHttpActionResult PutFederation(int id, FederationViewModel federation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != federation.Id)
            {
                return(BadRequest());
            }

            //db.Entry(federation).State = EntityState.Modified;
            using (var ctx = new Tuks_Athletics_SystemEntities())
            {
                var existingFederation = ctx.Federations.Where(s => s.Federation_ID == federation.Id).FirstOrDefault <Federation>();

                if (existingFederation != null)
                {
                    existingFederation.Name       = federation.Name;
                    existingFederation.Descrption = federation.Description;
                }

                try
                {
                    ctx.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FederationExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private async Task <FederationViewModel> BuildPartialFederationViewModelAsync(long fuid, TabType tab, ChartGroupType chartGroup, UnitType unitType)
        {
            var vm = new FederationViewModel(fuid, _benchmarkBasketService.GetSchoolBenchmarkList());

            vm.HistoricalCharts.AddRange(_historicalChartBuilder.Build(tab, chartGroup, vm.EstablishmentType, unitType));
            vm.ChartGroups = _historicalChartBuilder.Build(tab, vm.EstablishmentType).DistinctBy(c => c.ChartGroup).ToList();
            vm.LatestTerm  = await LatestFederationTermAsync();

            vm.Tab = tab;

            vm.ContextData = await _contextDataService.GetSchoolDataObjectByUrnAsync(fuid);

            vm.HistoricalFinancialDataModels = await GetFinancialDataHistoricallyAsync(fuid);

            _fcService.PopulateHistoricalChartsWithFinancialData(vm.HistoricalCharts, vm.HistoricalFinancialDataModels, vm.LatestTerm, vm.Tab, unitType, vm.EstablishmentType);

            vm.SchoolsInFederation = await _contextDataService.GetMultipleSchoolDataObjectsByUrnsAsync(vm.FederationMembersURNs.ToList());

            vm.LaName = _laService.GetLaName(vm.La.ToString());

            return(vm);
        }
Exemplo n.º 8
0
 private void browseButton_Click(object sender, RoutedEventArgs e)
 {
     errorMessage.Content = null;
     try
     {
         SessionBase.DoWindowsAuthentication = (bool)UseWindowsAuthentication.IsChecked;
         if (this.noServerButton.IsChecked == true)
         {
             session = new SessionNoServer(systemDatabaseDirectory.Text, 2000, (bool)OptimisticLocking.IsChecked);
         }
         else
         {
             session = new ServerClientSession(systemDatabaseDirectory.Text, systemDatabaseServer.Text, 2000, (bool)OptimisticLocking.IsChecked);
         }
         session.BeginRead();
         List <Database>     dbList    = session.OpenAllDatabases(); // keep a reference to each db so they don't get garbage collected
         FederationViewModel viewModel = new FederationViewModel(session.Databases, session);
         base.DataContext = viewModel;
     }
     catch (Exception ex)
     {
         errorMessage.Content = ex.Message == null?ex.ToString() :  ex.Message;
     }
 }
Exemplo n.º 9
0
 public void AddFederationToBenchmarkList(FederationViewModel fedVM)
 {
     AddSchoolToBenchmarkList(new BenchmarkSchoolModel(fedVM));
 }
Exemplo n.º 10
0
 public void SetFederationAsDefault(FederationViewModel benchmarkSchool)
 {
     UpdateSchoolComparisonListCookie(CookieActions.SetDefault, new BenchmarkSchoolModel(benchmarkSchool));
 }