示例#1
0
        private static ActionResult UpdateProjectGrantAllocationExpenditures(
            EditProjectGrantAllocationExpendituresViewModel viewModel,
            List <ProjectGrantAllocationExpenditure> currentProjectGrantAllocationExpenditures, Project project)
        {
            HttpRequestStorage.DatabaseEntities.ProjectGrantAllocationExpenditures.Load();
            var allProjectGrantAllocationExpenditures = HttpRequestStorage.DatabaseEntities.ProjectGrantAllocationExpenditures.Local;

            viewModel.UpdateModel(currentProjectGrantAllocationExpenditures, allProjectGrantAllocationExpenditures, project);

            return(new ModalDialogFormJsonResult());
        }
示例#2
0
        public PartialViewResult EditProjectGrantAllocationExpendituresForProject(ProjectPrimaryKey projectPrimaryKey)
        {
            var project = projectPrimaryKey.EntityObject;
            var projectGrantAllocationExpenditures = project.ProjectGrantAllocationExpenditures.ToList();
            var calendarYearRange           = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project);
            var projectExemptReportingYears = project.GetExpendituresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList();
            var currentExemptedYears        = projectExemptReportingYears.Select(x => x.CalendarYear).ToList();

            projectExemptReportingYears.AddRange(calendarYearRange.Where(x => !currentExemptedYears.Contains(x)).Select((x, index) => new ProjectExemptReportingYearSimple(-(index + 1), project.ProjectID, x)));
            var calendarYearRangeForExpenditures       = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project);
            var projectGrantAllocationExpenditureBulks = ProjectGrantAllocationExpenditureBulk.MakeFromList(projectGrantAllocationExpenditures, calendarYearRangeForExpenditures);
            var viewModel = new EditProjectGrantAllocationExpendituresViewModel(project, projectGrantAllocationExpenditureBulks, projectExemptReportingYears);

            return(ViewEditProjectGrantAllocationExpenditures(project, viewModel, calendarYearRangeForExpenditures));
        }
示例#3
0
        private PartialViewResult ViewEditProjectGrantAllocationExpenditures(Project project, EditProjectGrantAllocationExpendituresViewModel viewModel, List <int> calendarYearRangeForExpenditures)
        {
            var allGrantAllocations           = HttpRequestStorage.DatabaseEntities.GrantAllocations.ToList().Select(x => new GrantAllocationSimple(x)).OrderBy(p => p.DisplayName).ToList();
            var showNoExpendituresExplanation = project.GetExpendituresExemptReportingYears().Any();
            var viewData = new EditProjectGrantAllocationExpendituresViewData(new ProjectSimple(project), allGrantAllocations, calendarYearRangeForExpenditures, showNoExpendituresExplanation);

            return(RazorPartialView <EditProjectGrantAllocationExpenditures, EditProjectGrantAllocationExpendituresViewData, EditProjectGrantAllocationExpendituresViewModel>(viewData, viewModel));
        }
示例#4
0
        public ActionResult EditProjectGrantAllocationExpendituresForProject(ProjectPrimaryKey projectPrimaryKey, EditProjectGrantAllocationExpendituresViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;
            var currentProjectGrantAllocationExpenditures = project.ProjectGrantAllocationExpenditures.ToList();

            if (!ModelState.IsValid)
            {
                var calendarYearRangeForExpenditures = currentProjectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project);
                return(ViewEditProjectGrantAllocationExpenditures(project, viewModel, calendarYearRangeForExpenditures));
            }

            return(UpdateProjectGrantAllocationExpenditures(viewModel, currentProjectGrantAllocationExpenditures, project));
        }