Exemple #1
0
        private void SaveChangesToDraftReturn(ReportFiguresViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            ReportFiguresHelper.SaveFiguresToDraftReturn(viewModel, draftReturn);

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevant(draftReturn);
        }
Exemple #2
0
        public IActionResult ReportFiguresGet(string encryptedOrganisationId, int reportingYear)
        {
            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            var viewModel = new ReportFiguresViewModel();

            PopulateViewModel(viewModel, organisationId, reportingYear);

            DraftReturn draftReturn     = draftReturnService.GetDraftReturn(organisationId, reportingYear);
            Return      submittedReturn = viewModel.Organisation.GetReturn(reportingYear);

            ReportFiguresHelper.SetFigures(viewModel, draftReturn, submittedReturn);

            return(View("ReportFigures", viewModel));
        }
Exemple #3
0
        public IActionResult ReportFiguresPost(string encryptedOrganisationId, int reportingYear, ReportFiguresViewModel viewModel)
        {
            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            ReportFiguresHelper.ValidateUserInput(viewModel, Request, reportingYear);

            if (viewModel.HasAnyErrors())
            {
                PopulateViewModel(viewModel, organisationId, reportingYear);
                return(View("ReportFigures", viewModel));
            }

            SaveChangesToDraftReturn(viewModel, organisationId, reportingYear);

            string nextPageUrl = Url.Action("ReportOverview", "ReportOverview", new { encryptedOrganisationId, reportingYear });

            StatusMessageHelper.SetStatusMessage(Response, "Saved changes to draft", nextPageUrl);
            return(LocalRedirect(nextPageUrl));
        }