public PowershellNotificationChannelDefinitionValidator(INotificationSubscriptionProvider subscriptionProvider, IAppPathProvider appPathProvider)
        {
            this.RuleFor(r => r.DisplayName)
            .NotEmpty().WithMessage("Display name is required")
            .Must((item, propertyValue) => subscriptionProvider.IsUnique(item.DisplayName, item.Id)).WithMessage("The display name is already in use");

            this.RuleFor(r => r.Script)
            .SetValidator(new FileSelectionViewModelValidator(appPathProvider));
        }
        public NotificationChannelSelectionViewModel(AuditNotificationChannels model, INotificationSubscriptionProvider subscriptionProvider, IEventAggregator eventAggregator, INotifyModelChangedEventPublisher eventPublisher)
        {
            this.Model = model;
            this.subscriptionProvider = subscriptionProvider;

            this.SuccessSubscriptions = subscriptionProvider.GetSubscriptions(this.Model.OnSuccess);
            this.FailureSubscriptions = subscriptionProvider.GetSubscriptions(this.Model.OnFailure);

            this.AvailableSuccessSubscriptions = new BindableCollection <SubscriptionViewModel>(subscriptionProvider.Subscriptions.Except(this.SuccessSubscriptions));
            this.AvailableFailureSubscriptions = new BindableCollection <SubscriptionViewModel>(subscriptionProvider.Subscriptions.Except(this.FailureSubscriptions));

            eventAggregator.Subscribe(this);
            eventPublisher.Register(this);
        }
        public SmtpNotificationChannelDefinitionValidator(INotificationSubscriptionProvider subscriptionProvider, IAppPathProvider appPathProvider)
        {
            this.RuleFor(r => r.EmailAddresses).Must(t => t?.Count > 0).WithMessage("At least one email address is required");
            this.RuleFor(t => t.NewRecipient).EmailAddress().When(t => t != null).WithMessage("The value must be a valid email address");

            this.RuleFor(r => r.DisplayName)
            .NotEmpty().WithMessage("Display name is required")
            .Must((item, propertyValue) => subscriptionProvider.IsUnique(item.DisplayName, item.Id)).WithMessage("The display name is already in use");

            this.RuleFor(r => r.TemplateSuccess)
            .NotEmpty().WithMessage("A file must be provided")
            .Must(t => string.IsNullOrWhiteSpace(t) || File.Exists(appPathProvider.GetFullPath(t, appPathProvider.TemplatesPath))).WithMessage("The file does not exist");

            this.RuleFor(r => r.TemplateFailure)
            .NotEmpty().WithMessage("A file must be provided")
            .Must(t => string.IsNullOrWhiteSpace(t) || File.Exists(appPathProvider.GetFullPath(t, appPathProvider.TemplatesPath))).WithMessage("The file does not exist");
        }
        public WebhookNotificationChannelDefinitionValidator(INotificationSubscriptionProvider subscriptionProvider, IAppPathProvider appPathProvider)
        {
            this.RuleFor(r => r.Url).NotEmpty();
            this.RuleFor(r => r.ContentType).NotEmpty();
            this.RuleFor(r => r.HttpMethod).NotEmpty();

            this.RuleFor(r => r.DisplayName)
            .NotEmpty().WithMessage("Display name is required")
            .Must((item, propertyValue) => subscriptionProvider.IsUnique(item.DisplayName, item.Id)).WithMessage("The display name is already in use");

            this.RuleFor(r => r.TemplateSuccess)
            .NotEmpty().WithMessage("A file must be provided")
            .Must(t => string.IsNullOrWhiteSpace(t) || File.Exists(appPathProvider.GetFullPath(t, appPathProvider.TemplatesPath))).WithMessage("The file does not exist");

            this.RuleFor(r => r.TemplateFailure)
            .NotEmpty().WithMessage("A file must be provided")
            .Must(t => string.IsNullOrWhiteSpace(t) || File.Exists(appPathProvider.GetFullPath(t, appPathProvider.TemplatesPath))).WithMessage("The file does not exist");
        }
Esempio n. 5
0
 public WebhookNotificationChannelDefinitionViewModel(WebhookNotificationChannelDefinition model, IModelValidator <WebhookNotificationChannelDefinitionViewModel> validator, INotificationSubscriptionProvider subscriptionProvider, IAppPathProvider appPathProvider)
     : base(model)
 {
     this.appPathProvider = appPathProvider;
     this.Validator       = validator;
     this.Validate();
 }
Esempio n. 6
0
 public WebhookNotificationChannelDefinitionViewModelFactory(IAppPathProvider appPathProvider, INotificationSubscriptionProvider notificationSubscriptionProvider, IModelValidator <WebhookNotificationChannelDefinitionViewModel> validator)
 {
     this.appPathProvider = appPathProvider;
     this.notificationSubscriptionProvider = notificationSubscriptionProvider;
     this.validator = validator;
 }
 public NotificationChannelSelectionViewModelFactory(INotificationSubscriptionProvider subscriptionProvider, Func <IEventAggregator> eventAggregator, Func <INotifyModelChangedEventPublisher> eventPublisher)
 {
     this.subscriptionProvider = subscriptionProvider;
     this.eventAggregator      = eventAggregator;
     this.eventPublisher       = eventPublisher;
 }
Esempio n. 8
0
 public NotificationChannelSelectionViewModelFactory(INotificationSubscriptionProvider subscriptionProvider, IEventAggregator eventAggregator, INotifiableEventPublisher eventPublisher)
 {
     this.subscriptionProvider = subscriptionProvider;
     this.eventAggregator      = eventAggregator;
     this.eventPublisher       = eventPublisher;
 }
        public SmtpNotificationChannelDefinitionViewModel(SmtpNotificationChannelDefinition model, IModelValidator <SmtpNotificationChannelDefinitionViewModel> validator, INotificationSubscriptionProvider subscriptionProvider, IAppPathProvider appPathProvider)
            : base(model)
        {
            this.appPathProvider = appPathProvider;

            if (this.Model.EmailAddresses == null)
            {
                this.Model.EmailAddresses = new List <string>();
            }

            this.EmailAddresses = new BindableCollection <string>(this.Model.EmailAddresses);

            this.Validator = validator;
            this.Validate();
        }