コード例 #1
0
 public void UpdateModel(ProjectUpdateSetting projectUpdateSetting)
 {
     projectUpdateSetting.ProjectUpdateKickOffDate          = ProjectUpdateKickOffDate;
     projectUpdateSetting.ProjectUpdateCloseOutDate         = ProjectUpdateCloseOutDate;
     projectUpdateSetting.ProjectUpdateReminderInterval     = ProjectUpdateReminderInterval;
     projectUpdateSetting.EnableProjectUpdateReminders      = EnableProjectUpdateReminders.GetValueOrDefault(); // will never be null
     projectUpdateSetting.SendPeriodicReminders             = SendPeriodicReminders.GetValueOrDefault();        // will never be null
     projectUpdateSetting.SendCloseOutNotification          = SendCloseOutNotification.GetValueOrDefault();     // will never be null
     projectUpdateSetting.ProjectUpdateKickOffIntroContent  = ProjectUpdateKickOffIntroContent?.ToString();
     projectUpdateSetting.ProjectUpdateReminderIntroContent =
         ProjectUpdateReminderIntroContent?.ToString();
     projectUpdateSetting.ProjectUpdateCloseOutIntroContent =
         ProjectUpdateCloseOutIntroContent?.ToString();
     projectUpdateSetting.DaysBeforeCloseOutDateForReminder = DaysBeforeCloseOutDateForReminder;
 }
コード例 #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // these bools will never be null due to RequiredAttribute
            var fieldDefinitionLabelProject = FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel();

            if (EnableProjectUpdateReminders ?? false)
            {
                if (string.IsNullOrWhiteSpace(ProjectUpdateKickOffIntroContent?.ToString()))
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, HtmlString>(
                                     $"You must provide {fieldDefinitionLabelProject} Update Kick-off Email Content if {fieldDefinitionLabelProject} Update Reminders are enabled.",
                                     m => m.ProjectUpdateKickOffIntroContent));
                }
            }

            if (SendPeriodicReminders ?? false)
            {
                if (string.IsNullOrWhiteSpace(ProjectUpdateReminderIntroContent?.ToString()))
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, HtmlString>(
                                     $"You must provide {fieldDefinitionLabelProject} Update Reminder Email Content if Periodic Reminders are enabled.",
                                     m => m.ProjectUpdateReminderIntroContent));
                }

                if (!ProjectUpdateReminderInterval.HasValue)
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, int?>(
                                     $"You must provide a {fieldDefinitionLabelProject} Update Reminder Interval if Periodic Reminders are enabled.",
                                     m => m.ProjectUpdateReminderInterval));
                }
                else if (ProjectUpdateReminderInterval.Value < 7)
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, int?>(
                                     $"{fieldDefinitionLabelProject} Update Reminder Interval must be at least 7 days.",
                                     m => m.ProjectUpdateReminderInterval));
                }
                else if (ProjectUpdateReminderInterval > 365)
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, int?>(
                                     $"{fieldDefinitionLabelProject} Update Reminder Interval cannot be greater than 365 days.",
                                     m => m.ProjectUpdateReminderInterval));
                }
            }

            if (SendCloseOutNotification ?? false)
            {
                if (string.IsNullOrWhiteSpace(ProjectUpdateCloseOutIntroContent?.ToString()))
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, HtmlString>(
                                     $"You must provide {fieldDefinitionLabelProject} Update Close-out Email Content if {fieldDefinitionLabelProject} Update Close-out Reminders are enabled.",
                                     m => m.ProjectUpdateCloseOutIntroContent));
                }
                if (!DaysBeforeCloseOutDateForReminder.HasValue)
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, int?>(
                                     $"You must provide the Days before end date to send Close-out Reminder if {fieldDefinitionLabelProject} Update Close-out Reminders are enabled.",
                                     m => m.ProjectUpdateReminderInterval));
                }
                if (DaysBeforeCloseOutDateForReminder.HasValue && DaysBeforeCloseOutDateForReminder > 365)
                {
                    yield return(new SitkaValidationResult <EditProjectUpdateConfigurationViewModel, int?>(
                                     "Days before end date to send Close-out Reminder cannot be greater than 365 days.",
                                     m => m.DaysBeforeCloseOutDateForReminder));
                }
            }
        }