Example #1
0
        public PartialViewResult EditProjectFundingSourceExpendituresByCostType(ProjectPrimaryKey projectPrimaryKey)
        {
            var project                  = projectPrimaryKey.EntityObject;
            var calendarYearRange        = project.CalculateCalendarYearRangeForExpendituresWithoutAccountingForExistingYears();
            var projectRelevantCostTypes =
                project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Expenditures);
            var viewModel = new EditProjectFundingSourceExpendituresByCostTypeViewModel(project, calendarYearRange, projectRelevantCostTypes);

            return(ViewEditProjectFundingSourceExpendituresByCostType(project, calendarYearRange, viewModel));
        }
Example #2
0
        public PartialViewResult EditProjectFundingSourceExpendituresByCostType(ProjectPrimaryKey projectPrimaryKey)
        {
            var project                    = projectPrimaryKey.EntityObject;
            var calendarYearRange          = project.CalculateCalendarYearRangeForExpendituresWithoutAccountingForExistingYears();
            var costTypes                  = HttpRequestStorage.DatabaseEntities.CostTypes.ToList();
            var projectRelevantCostTypes   = project.GetExpendituresRelevantCostTypes().Select(x => new ProjectRelevantCostTypeSimple(x)).ToList();
            var currentRelevantCostTypeIDs = projectRelevantCostTypes.Select(x => x.CostTypeID).ToList();

            projectRelevantCostTypes.AddRange(
                costTypes.Where(x => !currentRelevantCostTypeIDs.Contains(x.CostTypeID))
                .Select((x, index) => new ProjectRelevantCostTypeSimple(-(index + 1), project.ProjectID, x.CostTypeID, x.CostTypeName)));
            var viewModel = new EditProjectFundingSourceExpendituresByCostTypeViewModel(project, calendarYearRange, projectRelevantCostTypes);

            return(ViewEditProjectFundingSourceExpendituresByCostType(project, calendarYearRange, viewModel));
        }
Example #3
0
        private PartialViewResult ViewEditProjectFundingSourceExpendituresByCostType(Project project, List <int> calendarYearRange, EditProjectFundingSourceExpendituresByCostTypeViewModel viewModel)
        {
            var showNoExpendituresExplanation = !string.IsNullOrWhiteSpace(project.ExpendituresNote);
            var allFundingSources             = HttpRequestStorage.DatabaseEntities.FundingSources.ToList().Select(x => new FundingSourceSimple(x)).OrderBy(p => p.DisplayName).ToList();
            var allCostTypes             = HttpRequestStorage.DatabaseEntities.CostTypes.ToList().Select(x => new CostTypeSimple(x)).OrderBy(p => p.CostTypeName).ToList();
            var viewDataForAngularEditor = new EditProjectFundingSourceExpendituresByCostTypeViewData.ViewDataForAngularClass(project, allFundingSources, allCostTypes, calendarYearRange, showNoExpendituresExplanation);
            var viewData = new EditProjectFundingSourceExpendituresByCostTypeViewData(viewDataForAngularEditor);

            return(RazorPartialView <EditProjectFundingSourceExpendituresByCostType, EditProjectFundingSourceExpendituresByCostTypeViewData, EditProjectFundingSourceExpendituresByCostTypeViewModel>(viewData, viewModel));
        }
Example #4
0
        public ActionResult EditProjectFundingSourceExpendituresByCostType(ProjectPrimaryKey projectPrimaryKey, EditProjectFundingSourceExpendituresByCostTypeViewModel viewModel)
        {
            var project           = projectPrimaryKey.EntityObject;
            var calendarYearRange = project.CalculateCalendarYearRangeForExpendituresWithoutAccountingForExistingYears();

            if (!ModelState.IsValid)
            {
                return(ViewEditProjectFundingSourceExpendituresByCostType(project, calendarYearRange, viewModel));
            }
            viewModel.UpdateModel(project, HttpRequestStorage.DatabaseEntities);
            return(new ModalDialogFormJsonResult());
        }