public ContentResult OnPostValidateNotificationSiteProperty([FromBody] InputValidationModel validationData)
        {
            var notificationSite = new NotificationSite
            {
                ShouldValidateFull = validationData.ShouldValidateFull,
                SiteId             = (int)SiteId.OTHER
            };

            return(ValidationService.GetPropertyValidationResult(notificationSite, validationData.Key, validationData.Value));
        }
        public ContentResult OnGetValidateNotificationSiteProperty(string key, string value, bool shouldValidateFull)
        {
            var notificationSite = new NotificationSite
            {
                ShouldValidateFull = shouldValidateFull,
                SiteId             = (int)SiteId.OTHER
            };

            return(ValidationService.GetPropertyValidationResult(notificationSite, key, value));
        }
Ejemplo n.º 3
0
        private static NotificationSite AsNotificationSite(MigrationDbSite result)
        {
            if (result.SiteId == null)
            {
                return(null);
            }

            var site = new NotificationSite();

            site.SiteId          = (int)result.SiteId;
            site.SiteDescription = result.SiteDescription;
            return(site);
        }
        protected override async Task <IActionResult> PrepareAndDisplayPageAsync(bool isBeingSubmitted)
        {
            ClinicalDetails = Notification.ClinicalDetails;
            await SetNotificationProperties(isBeingSubmitted, ClinicalDetails);

            var notificationSites = Notification.NotificationSites;

            notificationSites.ForEach(x => x.ShouldValidateFull = Notification.ShouldValidateFull);

            SetupNotificationSiteMap(notificationSites);
            OtherSite = new NotificationSite
            {
                SiteId             = (int)SiteId.OTHER,
                SiteDescription    = notificationSites.FirstOrDefault(ns => ns.SiteId == (int)SiteId.OTHER)?.SiteDescription,
                ShouldValidateFull = Notification.ShouldValidateFull
            };
            Sites = (await _referenceDataRepository.GetAllSitesAsync()).ToList();

            PatientBirthYear = Notification.PatientDetails.Dob?.Year;

            FormattedSymptomDate               = ClinicalDetails.SymptomStartDate.ConvertToFormattedDate();
            FormattedFirstPresentationDate     = ClinicalDetails.FirstPresentationDate.ConvertToFormattedDate();
            FormattedTbServicePresentationDate = ClinicalDetails.TBServicePresentationDate.ConvertToFormattedDate();
            FormattedDiagnosisDate             = ClinicalDetails.DiagnosisDate.ConvertToFormattedDate();
            FormattedTreatmentDate             = ClinicalDetails.TreatmentStartDate.ConvertToFormattedDate();
            FormattedMdrTreatmentDate          = ClinicalDetails.MDRTreatmentStartDate.ConvertToFormattedDate();
            FormattedHomeVisitDate             = ClinicalDetails.FirstHomeVisitDate.ConvertToFormattedDate();

            if (ClinicalDetails.ShouldValidateFull)
            {
                TryValidateModel(this);

                // EditPageErrorDictionary is null only if coming from a GET call, we want to guard here
                // only in a GET call
                if (EditPageErrorDictionary == null &&
                    (!NotificationSiteMap.ContainsKey(SiteId.OTHER) || !NotificationSiteMap[SiteId.OTHER]))
                {
                    ModelState.Remove("OtherSite.SiteDescription");
                }
            }

            return(Page());
        }