public TrustViewModel GetTrustModules(int trustId)
        {
            TrustViewModel trustViewModel = new TrustViewModel();

            if (trustId > 0)
            {
                var trust = _trustService.GetTrustById(trustId);

                trustViewModel.Id   = trustId;
                trustViewModel.Name = trust.Name;

                var trustModuleViewModelList = (from m in _context.Modules
                                                join tm in _context.TrustModules on new { mid = m.Id, tid = trustId } equals new { mid = tm.ModuleId, tid = tm.TrustId } into tmdef
                                                from tm in tmdef.DefaultIfEmpty()
                                                select new TrustModuleViewModel
                {
                    Id = tm != null ? tm.Id : 0,
                    ModuleId = m.Id,
                    ModuleName = m.Name,
                    TrustId = tm != null ? tm.TrustId : 0,
                    IsHaveAccess = tm != null
                }).ToList();

                trustViewModel.TrustModuleViewModelList = trustModuleViewModelList;
            }
            return(trustViewModel);
        }
        private async Task <TrustViewModel> BuildFinancialTrustVMAsync(int companyNo, TabType tab, ChartGroupType chartGroup, MatFinancingType matFinancing)
        {
            var comparisonListVM = _benchmarkBasketService.GetSchoolBenchmarkList();
            var trustVM          = new TrustViewModel(companyNo, comparisonListVM);

            trustVM.HistoricalCharts = _historicalChartBuilder.Build(tab, chartGroup, trustVM.EstablishmentType);
            trustVM.ChartGroups      = _historicalChartBuilder.Build(tab, trustVM.EstablishmentType).DistinctBy(c => c.ChartGroup).ToList();
            trustVM.LatestTerm       = await LatestMATTermAsync();

            trustVM.HistoricalFinancialDataModels = await this.GetFinancialDataHistoricallyAsync(trustVM.CompanyNo, matFinancing);

            trustVM.AcademiesInFinanceList = (await _financialDataService.GetAcademiesByCompanyNumberAsync(await LatestMATTermAsync(), companyNo)).OrderBy(a => a.EstablishmentName).ToList();

            return(trustVM);
        }
Beispiel #3
0
        public ActionResult StepOne(int companyNo, string matName, ComparisonType?comparisonType)
        {
            switch (comparisonType)
            {
            case ComparisonType.Advanced:
                return(Redirect($"/TrustComparison/Advanced?companyNo={companyNo}"));

            case ComparisonType.Manual:
                return(Redirect($"/TrustComparison/Manual?companyNo={companyNo}"));

            default:
                var model = new TrustViewModel(companyNo, matName);
                model.ErrorMessage = ErrorMessages.SelectComparisonType;
                return(View("SelectType", model));
            }
        }
        public async Task UpdateTrustModule(TrustViewModel trustViewModel)
        {
            if (trustViewModel != null && trustViewModel.TrustModuleViewModelList != null && trustViewModel.TrustModuleViewModelList.Count() > 0)
            {
                var moduleIds = trustViewModel.TrustModuleViewModelList.Select(x => x.ModuleId).ToList();

                _context.TrustModules.RemoveRange(_context.TrustModules.Where(x => x.TrustId == trustViewModel.Id && moduleIds.Contains(x.ModuleId)));
                _context.RolePermissions.RemoveRange(_context.RolePermissions.Where(x => x.Permission != null && moduleIds.Contains(x.Permission.ModuleId ?? 0)));

                foreach (var trustModule in trustViewModel.TrustModuleViewModelList.Where(x => x.IsHaveAccess))
                {
                    _context.TrustModules.Add(new TrustModule()
                    {
                        TrustId = trustViewModel.Id, ModuleId = trustModule.ModuleId
                    });
                }
                await _context.SaveChangesAsync();
            }
        }
Beispiel #5
0
        public async Task <TrustViewModel> SetTrustAsDefaultAsync(int companyNo)
        {
            var latestTerm = await LatestMATTermAsync();

            var trustFinancialDataObject = await _financialDataService.GetTrustFinancialDataObjectByCompanyNoAsync(companyNo, latestTerm, MatFinancingType.TrustAndAcademies);

            TryAddTrustToBenchmarkList(companyNo, trustFinancialDataObject.TrustOrCompanyName);

            UpdateTrustComparisonListCookie(CookieActions.SetDefault, companyNo, trustFinancialDataObject.TrustOrCompanyName);

            var vm = new TrustViewModel(companyNo, trustFinancialDataObject.TrustOrCompanyName);

            vm.HistoricalFinancialDataModels = new List <FinancialDataModel>
            {
                new FinancialDataModel(companyNo.ToString(), latestTerm, trustFinancialDataObject, EstablishmentType.MAT)
            };

            return(vm);
        }
Beispiel #6
0
        public async Task <ActionResult> ManageModule(TrustViewModel trustViewModel)
        {
            await _moduleService.UpdateTrustModule(trustViewModel);

            return(RedirectToAction("ManageModule"));
        }
 public TrustSelectionViewModel(TrustViewModel trust, TrustComparisonListModel trustComparisonList)
 {
     this.TrustComparisonList = trustComparisonList;
     this.BenchmarkTrust      = trust;
 }
Beispiel #8
0
        public ViewResult SelectType(int companyNo, string matName)
        {
            var model = new TrustViewModel(companyNo, matName);

            return(View(model));
        }
Beispiel #9
0
 public TrustScene()
 {
     DataContext = new TrustViewModel(MainWindow.ffInstance, MainWindow.api, MainWindow.thirdPartyTools);
     InitializeComponent();
 }