Esempio n. 1
0
        private bool WebsiteLinkSectionIsComplete(DraftReturn draftReturn)
        {
            // The website link is optional, so we should allow it to be missing
            bool linkIsMissing = string.IsNullOrEmpty(draftReturn.CompanyLinkToGPGInfo);
            bool linkIsValid   = UriSanitiser.IsValidHttpOrHttpsLink(draftReturn.CompanyLinkToGPGInfo);

            return(linkIsMissing || linkIsValid);
        }
        private void ValidateUserInput(ReportLinkToWebsiteViewModel viewModel)
        {
            viewModel.ParseAndValidateParameters(Request, m => m.LinkToOrganisationWebsite);

            if (!string.IsNullOrEmpty(viewModel.LinkToOrganisationWebsite))
            {
                if (!UriSanitiser.IsValidHttpOrHttpsLink(viewModel.LinkToOrganisationWebsite))
                {
                    viewModel.AddErrorFor(m => m.LinkToOrganisationWebsite, "Please enter a valid web address");
                }
            }
        }
        private void ValidateUserInput(ReportLinkToWebsiteViewModel viewModel)
        {
            viewModel.ParseAndValidateParameters(Request, m => m.LinkToOrganisationWebsite);

            if (!string.IsNullOrEmpty(viewModel.LinkToOrganisationWebsite))
            {
                if (!UriSanitiser.IsValidHttpOrHttpsLink(viewModel.LinkToOrganisationWebsite))
                {
                    viewModel.AddErrorFor(m => m.LinkToOrganisationWebsite, "Enter a valid URL, starting with http:// or https://");
                }
            }
        }
        public bool DraftReturnExistsAndIsComplete(long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = GetDraftReturn(organisationId, reportingYear);

            if (draftReturn == null)
            {
                return(false);
            }

            Organisation organisation = dataRepository.Get <Organisation>(organisationId);

            // Hourly pay
            bool hourlyPaySectionIsComplete =
                draftReturn.DiffMeanHourlyPayPercent != null &&
                draftReturn.DiffMedianHourlyPercent != null;

            // Bonus pay
            bool noBonusesPaid =
                draftReturn.MaleMedianBonusPayPercent == 0 &&
                draftReturn.FemaleMedianBonusPayPercent == 0;

            bool allValuesComplete =
                draftReturn.MaleMedianBonusPayPercent != null &&
                draftReturn.FemaleMedianBonusPayPercent != null &&
                draftReturn.DiffMeanBonusPercent != null &&
                draftReturn.DiffMedianBonusPercent != null;

            bool bonusPaySectionIsComplete = noBonusesPaid || allValuesComplete;

            // Employees by pay quartile
            bool employeesByPayQuartileSectionIsComplete =
                draftReturn.MaleLowerPayBand != null &&
                draftReturn.FemaleLowerPayBand != null &&
                draftReturn.MaleMiddlePayBand != null &&
                draftReturn.FemaleMiddlePayBand != null &&
                draftReturn.MaleUpperPayBand != null &&
                draftReturn.FemaleUpperPayBand != null &&
                draftReturn.MaleUpperQuartilePayBand != null &&
                draftReturn.FemaleUpperQuartilePayBand != null;

            // Responsible person
            bool responsiblePersonSectionIsComplete =
                organisation.SectorType == SectorTypes.Public || // Public sector organisations don't have to provide a responsible person
                (!string.IsNullOrWhiteSpace(draftReturn.FirstName) &&
                 !string.IsNullOrWhiteSpace(draftReturn.LastName) &&
                 !string.IsNullOrWhiteSpace(draftReturn.JobTitle));

            // Organisation size
            bool organisationSizeSectionIsComplete = draftReturn.OrganisationSize != null;

            // Website link
            // The website link is optional, so we should allow it to be missing
            bool linkIsMissing = string.IsNullOrEmpty(draftReturn.CompanyLinkToGPGInfo);
            bool linkIsValid   = UriSanitiser.IsValidHttpOrHttpsLink(draftReturn.CompanyLinkToGPGInfo);
            bool websiteLinkSectionIsComplete = linkIsMissing || linkIsValid;

            return(hourlyPaySectionIsComplete &&
                   bonusPaySectionIsComplete &&
                   employeesByPayQuartileSectionIsComplete &&
                   responsiblePersonSectionIsComplete &&
                   organisationSizeSectionIsComplete &&
                   websiteLinkSectionIsComplete);
        }