public MultiValidatorPanel(UIElement content, UIElement[] elements, DependencyProperty property, IValidate validation, ValidationAggregationType type)
        {
            Content = content;

            MultiBinding multiBinding = new MultiBinding();
            switch (type)
            {
                case ValidationAggregationType.And:
                    multiBinding.Converter = new AndValidationConverter(validation);
                    break;
                case ValidationAggregationType.Or:
                    multiBinding.Converter = new OrValidationConverter(validation);
                    break;
            }

            for (var i = 0; i < elements.Length; ++i)
            {
                Binding b =
                    new Binding()
                    {
                        Source = elements[i],
                        Path = new PropertyPath(property.Name),
                        Mode = BindingMode.OneWay
                    };
                multiBinding.Bindings.Add(b);
            }
            this.SetBinding(ValidProperty, multiBinding);
        }
 public ShowFixInfo(DataTable p_dtSource)
 {
     if (!m_dtSource.Columns.Contains("TARGET"))
     {
         m_dtSource.Columns.Add("TARGET");
     }
     if (!m_dtSource.Columns.Contains("FIT"))
     {
         m_dtSource.Columns.Add("FIT");
     }
     InitializeComponent();
     string _strExportType = uctlBaseConfig.GetConfig("ExportType");
     switch (_strExportType)
     {
         case "DB":
             m_ivalidate = new ExportDB();
             break;
         case "XML":
             m_ivalidate = new ExportXml();
             break;
         case "DBF":
             break;
         case "EXCEL":
             break;
     }
     m_ivalidate.ValidateAll(p_dtSource);
     string _strFile = Application.StartupPath + "\\error\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\validate.error";
     Process.Start("notepad.exe",_strFile);
 }
 public ShowFixInfo(string p_strTableName,string p_strMS)
 {
     if (!m_dtSource.Columns.Contains("TARGET"))
     {
         m_dtSource.Columns.Add("TARGET");
     }
     if (!m_dtSource.Columns.Contains("FIT"))
     {
         m_dtSource.Columns.Add("FIT");
     }
     InitializeComponent();
     string _strExportType = uctlBaseConfig.GetConfig("ExportType");
     switch (_strExportType) {
         case "DB":
             m_ivalidate = new ExportDB();
             break;
         case "XML":
             m_ivalidate = new ExportXml();
             break;
         case "DBF":
             break;
         case "EXCEL":
             break;
     }
     m_ivalidate.ValidateData(p_strTableName);
     dataGridView2.DataSource = m_dtSource.DefaultView;
     textBox2.Text = m_strWarning;
 }
示例#4
0
        protected static List<ValidationError> Validate(IValidate toValidate, out bool IsValid)
        {
            IsValid = false; // Guilty until proven innocent.

            if (toValidate == null)
                throw new SageException("No Payment Set");

            var errors = toValidate.Validate();
            IsValid = !errors.Any();
            return errors;
        }
        public ValidatorPanel(UIElement element, DependencyProperty property, IValidate validation)
        {
            Content = element;

            Binding binding =
                new Binding()
                {
                    Source = element,
                    Path = new PropertyPath(property.Name),
                    Mode = BindingMode.OneWay,
                    Converter = new ValidationConverter(validation)
                };
            base.SetBinding(ValidProperty, binding);
        }
        public PKDetectorEventCounter(Header.Header hdr, IValidate v)
        {
            this.header = hdr;
            this.validate = v;

            InitializeComponent();

            foreach (string str in hdr.Events.Keys)
                if (str.Substring(0, 7) == "**PKDet") EventSelection.Items.Add(str.Substring(7)); //Add to Event selection list
            EventSelection.SelectedIndex = 0;
            Comp1.Items.Add("<");
            Comp1.Items.Add(">");
            Comp1.SelectedIndex = 0;
            Comp2.Items.Add(">");
            Comp2.Items.Add("<");
            Comp2.SelectedIndex = 0;
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "AdviserDetails")] HttpRequestMessage req, ILogger log,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPostAdviserDetailHttpTriggerService adviserDetailsPostService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Post Adviser Detail C# HTTP trigger function processed a request. " + touchpointId);

            Models.AdviserDetail adviserDetailRequest;

            try
            {
                adviserDetailRequest = await httpRequestMessageHelper.GetAdviserDetailFromRequest <Models.AdviserDetail>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (adviserDetailRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            adviserDetailRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(adviserDetailRequest, true);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var adviserDetail = await adviserDetailsPostService.CreateAsync(adviserDetailRequest);

            return(adviserDetail == null
                ? HttpResponseMessageHelper.BadRequest()
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(adviserDetail)));
        }
示例#8
0
        //验证一个对象是否符合要求
        private static string Valid(object obj)
        {
            // 1. 找出obj 里面里面的所有的属性
            Type t = obj.GetType();

            PropertyInfo[] properties = t.GetProperties();
            StringBuilder  sb         = new StringBuilder();

            for (int i = 0; i < properties.Length; i++)
            {
                // 2. 获取对象相对于此属性的值
                object value = t.InvokeMember(properties[i].Name, BindingFlags.GetProperty, null, obj, null);
                // 3. 看看属性上面有没有验证标示(特性)
                object[] attributes = properties[i].GetCustomAttributes(true);
                if (attributes.Length > 0)
                {
                    for (int j = 0; j < attributes.Length; j++)
                    {
                        // 4. 判断这个特性是否为验证特性
                        if (attributes[j] is IValidate)
                        {
                            IValidate validate = attributes[j] as IValidate;
                            // 5. 验证当前属性是否符合要求
                            string msg = validate.Validate(value);
                            if (!string.IsNullOrEmpty(msg))
                            {
                                sb.AppendLine(msg);
                            }
                        }
                        else if (attributes[j] is IValidationSuper)
                        {
                            IValidationSuper validate = attributes[j] as IValidationSuper;
                            // 5. 验证当前属性是否符合要求
                            string msg = validate.Validate(obj, properties[i].Name);
                            if (!string.IsNullOrEmpty(msg))
                            {
                                sb.AppendLine(msg);
                            }
                        }
                    }
                }
            }

            return(sb.ToString());
        }
示例#9
0
        public void ReadXml(XmlReader reader)
        {
            string fullName = "";

            fullName = reader.ReadString() ?? "";
            IValidate <T> result = null;

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                result = assembly.CreateInstance(fullName) as IValidate <T>;
            }
            catch (Exception)
            {
            }
            reader.ReadEndElement();
            m_Validate = result;
        }
        public void Setup()
        {
            _transfer = new Models.Transfer()
            {
                TargetTouchpointId = "0000000002", Context = "some context"
            };

            _request = new DefaultHttpRequest(new DefaultHttpContext());

            _log                            = new Mock <ILogger>();
            _resourceHelper                 = new Mock <IResourceHelper>();
            _httpRequestMessageHelper       = new Mock <IHttpRequestHelper>();
            _validate                       = new Validate();
            _postTransferHttpTriggerService = new Mock <IPostTransferHttpTriggerService>();
            _jsonHelper                     = new JsonHelper();
            _responseHelper                 = new HttpResponseMessageHelper();
            _function                       = new PostTransferHttpTrigger.Function.PostTransferHttpTrigger(_resourceHelper.Object, _httpRequestMessageHelper.Object, _validate, _postTransferHttpTriggerService.Object, _responseHelper, _jsonHelper);
        }
        public void Setup()
        {
            _diversity = Substitute.For <Models.Diversity>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/DiversityDetails/")
            };

            _log            = Substitute.For <ILogger>();
            _resourceHelper = Substitute.For <IResourceHelper>();
            _postDiversityHttpTriggerService = Substitute.For <IPostDiversityHttpTriggerService>();
            _validate = Substitute.For <IValidate>();
            _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetDiversityFromRequest <Models.Diversity>(_request).Returns(Task.FromResult(_diversity).Result);
        }
        public void Setup()
        {
            _address = Substitute.For <Models.Address>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/Addressess/")
            };

            _log                           = Substitute.For <ILogger>();
            _resourceHelper                = Substitute.For <IResourceHelper>();
            _httpRequestMessageHelper      = Substitute.For <IHttpRequestMessageHelper>();
            _validate                      = Substitute.For <IValidate>();
            _postAddressHttpTriggerService = Substitute.For <IPostAddressHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }
示例#13
0
        public UploadController(ILogger <UploadController> logger, IMemoryCache cache, IValidate validate, IConfiguration configuration, IProspectListRepository prospectListRepository)
        {
            _logger = logger;
            // _callAssignRepository = callAssignRepository;
            _validate = validate;
            _config   = configuration;

            //need to read from config
            //_fileSizeLimit = config.GetValue<long>("FileSizeLimit");
            _fileSizeLimit = MAX_FILE_SIZE;
            _cache         = cache;

            // To save physical files to a path provided by configuration:
            //_targetFilePath = config.GetValue<string>("StoredFilesPath");

            // To save physical files to the temporary files folder, use:
            _targetFilePath         = Path.GetTempPath();
            _prospectListRepository = prospectListRepository;
        }
示例#14
0
        public static OperationResult Validate(this IValidate validatable)
        {
            if (validatable == null)
            {
                return(new OperationResult
                {
                    Status = false,
                    Message = "The object is null"
                });
            }

            var errorMessage = validatable.GetErrors();

            return(new OperationResult
            {
                Status = string.IsNullOrEmpty(errorMessage),
                Message = errorMessage
            });
        }
        public Repository(ICollection <T> items, ILogger logger, IValidate <T, I> validate)
        {
            if (items == null)
            {
                throw new ArgumentNullException("Items collection cannot be null");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("Logger cannot be null");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("Logger cannot be null");
            }

            this.items    = items;
            this.logger   = logger;
            this.validate = validate;
        }
        public void Setup()
        {
            _address      = Substitute.For <Models.AdviserDetail>();
            _addressPatch = Substitute.For <Models.AdviserDetailPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"AdviserDetails/1e1a555c-9633-4e12-ab28-09ed60d51cb3")
            };

            _log      = Substitute.For <ILogger>();
            _validate = Substitute.For <IValidate>();
            _httpRequestMessageHelper             = Substitute.For <IHttpRequestMessageHelper>();
            _patchAdviserDetailHttpTriggerService = Substitute.For <IPatchAdviserDetailHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("00000000001");
        }
示例#17
0
        public ValidateModsViewModel(IComponentContext components)
        {
            _viewController    = components.Resolve <IViewController>();
            _validate          = components.Resolve <IValidate>();
            _fileSystemBrowser = components.Resolve <IFileSystemBrowser>();
            _nxmHandle         = components.Resolve <INxmHandle>();
            _apiEndpoints      = components.Resolve <IApiEndpoints>();
            _downloadClient    = components.Resolve <IDownloadClient>();
            _apiBase           = components.Resolve <IApiBase>();
            _installBase       = components.Resolve <IInstallBase>();
            _dialogController  = components.Resolve <IDialogController>();
            _logger            = components.Resolve <ILogger>();

            _viewController.ViewIndexChangedEvent += ViewControllerOnViewIndexChangedEvent;
            _nxmHandle.RecievedPipedDataEvent     += QueueDownload;
            _downloadClient.DownloadUpdate        += DownloadUpdate;

            BindingOperations.EnableCollectionSynchronization(MissingMods, _missingModsLocked);
        }
示例#18
0
        void Events_OnCreateChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            IFeature inFeature = (IFeature)obj;

            if (inFeature.Class is IValidation)
            {
                IValidate validate = (IValidate)inFeature;
                string    errorMessage;
                //Validates connectivity rules, relationship rules, topology rules etc
                bool bIsvalid = validate.Validate(out errorMessage);
                if (!bIsvalid)
                {
                    System.Windows.Forms.MessageBox.Show("Invalid Feature\n\n" + errorMessage);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Valid Feature");
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.user_registration);

            submitButton        = FindViewById <Button>(Resource.Id.submitButton);
            submitButton.Click += OnSubmit;

            firstName = FindViewById <TextInputEditText>(Resource.Id.firstNameInput);
            lastName  = FindViewById <TextInputEditText>(Resource.Id.lastNameInput);
            age       = FindViewById <TextInputEditText>(Resource.Id.ageInput);

            passwordInputField = FindViewById <TextInputEditText>(Resource.Id.passwordInput);
            passwordInputField.AddTextChangedListener(this);

            userValidation = new UserValidation();

            db = DataBaseService.Instance;
        }
示例#20
0
        public void Setup()
        {
            _session      = Substitute.For <Session>();
            _sessionPatch = Substitute.For <SessionPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Sessions/1e1a555c-9633-4e12-ab28-09ed60d51cb3")
            };

            _log                            = Substitute.For <ILogger>();
            _resourceHelper                 = Substitute.For <IResourceHelper>();
            _validate                       = Substitute.For <IValidate>();
            _httpRequestMessageHelper       = Substitute.For <IHttpRequestMessageHelper>();
            _patchSessionHttpTriggerService = Substitute.For <IPatchSessionHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }
示例#21
0
        public void Setup()
        {
            _session = Substitute.For <Models.Session>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Interactions/aa57e39e-4469-4c79-a9e9-9cb4ef410382/" +
                            $"Sessions")
            };

            _log                           = Substitute.For <ILogger>();
            _resourceHelper                = Substitute.For <IResourceHelper>();
            _httpRequestMessageHelper      = Substitute.For <IHttpRequestMessageHelper>();
            _validate                      = Substitute.For <IValidate>();
            _postSessionHttpTriggerService = Substitute.For <IPostSessionHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }
        public void Setup()
        {
            _transfer = new Models.Transfer()
            {
                LastModifiedTouchpointId = "0000000001"
            };
            _transferPatch = new TransferPatch()
            {
                LastModifiedTouchpointId = "0000000001", TargetTouchpointId = "0000000002"
            };

            _request = new DefaultHttpRequest(new DefaultHttpContext());

            _log                             = new Mock <ILogger>();
            _resourceHelper                  = new Mock <IResourceHelper>();
            _validate                        = new Validate();
            _httpRequestMessageHelper        = new Mock <IHttpRequestHelper>();
            _patchTransferHttpTriggerService = new Mock <IPatchTransferHttpTriggerService>();
            _jsonHelper                      = new JsonHelper();
            _responseHelper                  = new HttpResponseMessageHelper();
            _function                        = new PatchTransferHttpTrigger.Function.PatchTransferHttpTrigger(_resourceHelper.Object, _httpRequestMessageHelper.Object, _validate, _patchTransferHttpTriggerService.Object, _responseHelper, _jsonHelper);
        }
        public EpisodeDescriptionEntry(Header.Header head, IValidate v)
        {
            this.hdr = head;
            this.validate = v;

            InitializeComponent();

            EventDictionary.EventDictionary events = hdr.Events;
            Event1.Items.Add("Any Event");
            Event1.Items.Add("Beginning of file");
            Event2.Items.Add("Same Event");
            Event2.Items.Add("Next Event (any)");
            Event2.Items.Add("Next Event (covered)");
            Event3.Items.Add("None");
            Event4.Items.Add("Same Event");
            foreach (EventDictionary.EventDictionaryEntry ev in events.Values){
                Event1.Items.Add(ev);
                Event2.Items.Add(ev);
                Event3.Items.Add(ev);
                Event4.Items.Add(ev);
            }
            Event1.SelectedIndex = 0;
            Event2.SelectedIndex = 0;
            Event3.SelectedIndex = 0;
            Event4.SelectedIndex = 0;
            Event4.IsEnabled = false;
            Comp1.Items.Add("=");
            Comp1.Items.Add("!=");
            Comp2.Items.Add("=");
            Comp2.Items.Add("!=");

            _GVspec = ++EDcount;
            GVSpec.Text = _GVspec.ToString("0");

            bool test = false;
            foreach (string ev in hdr.Events.Keys)
                if (ev.Substring(0, 7) == "**PKDet") { test = true; break; } //make sure there are PK detector Events present
            if (!test) AddCounterEvent.IsEnabled = false;
        }
示例#24
0
        public PasswordUpdateDialogViewModel(IValidate <SecureString> originalValidator, IValidate <SecureString> confirmValidator)
        {
            SuccessEnableCallback = defaultEnable =>
                                    (Password.HasErrors || ConfirmPassword.HasErrors) == false;

            Password.Validator = originalValidator;
            if (confirmValidator is NullValidator <SecureString> )
            {
                confirmValidator = new CallbackValidator <SecureString>(o =>
                                                                        Password.Password.Length != 0 && Perform.SecureStringCompare(Password.Password, ConfirmPassword.Password) ?
                                                                        new OperationResult() :
                                                                        new OperationResult(new[] { new ValidationFailedException("Both fields must match.") })
                                                                        );
            }
            ConfirmPassword.Validator = confirmValidator;

            Password.PropertyChanged        += Password_PropertyChanged;
            ConfirmPassword.PropertyChanged += Password_PropertyChanged;

            Password.RunValidation();
            ConfirmPassword.RunValidation();
        }
示例#25
0
        public void Setup()
        {
            _goal      = Substitute.For <Models.Goal>();
            _goalPatch = Substitute.For <GoalPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Interactions/aa57e39e-4469-4c79-a9e9-9cb4ef410382/" +
                            $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51/" +
                            $"Goals/d5369b9a-6959-4bd3-92fc-1583e72b7e51")
            };

            _log                         = Substitute.For <ILogger>();
            _resourceHelper              = Substitute.For <IResourceHelper>();
            _validate                    = Substitute.For <IValidate>();
            _httpRequestMessageHelper    = Substitute.For <IHttpRequestMessageHelper>();
            _patchGoalHttpTriggerService = Substitute.For <IPatchGoalHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }
示例#26
0
        public static bool CheckValidate <T>(this Type type, T obj) where T : class
        {
            //Type type = typeof(T);
            var props = type.GetProperties();
            //用于记录错误信息
            StringBuilder sb = new StringBuilder();

            foreach (var item in props)
            {
                //1:获取item的验证特性
                object[] customs = item.GetCustomAttributes(true);
                if (customs.Length == 0)
                {
                    continue;
                }
                //2:检查特性是否满足
                foreach (var attr in customs)
                {
                    IValidate validate = attr as IValidate;
                    if (validate != null)
                    {
                        bool isValidate = validate.IsValidate(item.GetValue(obj));
                        if (!isValidate)
                        {
                            sb.AppendLine($"属性:{item.Name} 验证失败,错误信息:{validate.ErrorMsg}");
                        }
                    }
                }
            }

            if (sb.ToString().Length > 0)
            {
                logger.Error(sb.ToString());
                return(false);
            }
            return(true);
        }
        public virtual IValidate Copy(IValidate other)
        {
            if (other is ValidatorRule <TData, TElement> )
            {
                var thatRef = other as ValidatorRule <TData, TElement>;

                //base.Copy(that);
                thatRef.OpenApiElementName      = this.OpenApiElementName;
                thatRef.RequestElementName      = this.RequestElementName;
                thatRef.RuleCode                = this.RuleCode;
                thatRef.LocalizationResourceKey = this.LocalizationResourceKey;

                foreach (var rule in Rules)
                {
                    var clonedObj = rule.Clone();
                    if (clonedObj is IValidate)
                    {
                        thatRef.Rules.Add(clonedObj as IValidate);
                    }
                }
                return(thatRef);
            }
            return(other);
        }
示例#28
0
        /// <summary>
        /// 校验对象属性值是否合法
        /// </summary>
        /// <param name="obj">待校验对象</param>
        /// <returns></returns>
        public static ValidateResult Validate(this IValidate obj)
        {
            ValidateResult result = new ValidateResult();

            PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo p in infos)
            {
                //获取数据校验特性。
                Attribute[] attrs = Attribute.GetCustomAttributes(p, typeof(ValidateAttribute), false);
                if (attrs.Length <= 0)
                {
                    continue;
                }

                //获取名称描述特性
                CaptionAttribute caption = Attribute.GetCustomAttribute(p, typeof(CaptionAttribute), false) as CaptionAttribute;
                object           value   = p.GetValue(obj);

                foreach (Attribute attr in attrs)
                {
                    ValidateAttribute validate = attr as ValidateAttribute;
                    if (validate == null)
                    {
                        continue;
                    }

                    result = Validate(validate, value, caption);
                    if (!result.IsSuccess)
                    {
                        return(result);
                    }
                }
            }
            return(result);
        }
示例#29
0
        /// <summary>
        /// Instantiates the <see cref="FindViewModel{TDataGridSource, TDataCollector}"/> class.
        /// </summary>
        /// <param name="validator">The validator used.</param>
        /// <param name="dataCollectorInitializer">A function which initializes the <see cref="DataCollector"/>.</param>
        public FindViewModel(IValidate <string> validator, Func <TDataCollector> dataCollectorInitializer)
        {
            Validator = validator;

            Search        = new AwaitableDelegateCommand(PrivateSearchCallback, SearchEnable);
            Clear         = new AwaitableDelegateCommand(PrivateClearCallback, ClearEnable);
            RecordRequest = new AwaitableDelegateCommand(RecordRequestCallback, () => true);

            _formLocker.LockStatusChanged += (s, e) => OnPropertyChanged(nameof(Disable));
            _formLocker.LockStatusChanged += (s, e) => OnDisableChange?.Invoke(this, new GenericEventArgs <bool>(Disable));

            _clearingLocker.LockStatusChanged += (s, e) => OnPropertyChanged(nameof(Clearing));

            DataCollector = dataCollectorInitializer();

            ResetStringProperties();

            var currentItems = new ObservableCollection <IIdProvider>();

            CurrentItems = currentItems;

            _synchronizer = new XAML.Behaviors.TwoListSynchronizer(ItemsFound, currentItems, new XAML.Behaviors.CallbackListItemConverter(null, ConvertFromCurrentItemsToItemsFound));
            _synchronizer.StartSynchronizing();
        }
        public void Setup()
        {
            _action      = Substitute.For <Models.Action>();
            _actionPatch = Substitute.For <ActionPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Interactions/1e1a555c-9633-4e12-ab28-09ed60d51cb3" +
                            $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51" +
                            $"Actions/233d861d-05ca-496e-aee1-6bd47ac13cb2")
            };

            _log                           = Substitute.For <ILogger>();
            _resourceHelper                = Substitute.For <IResourceHelper>();
            _validate                      = Substitute.For <IValidate>();
            _httpRequestMessageHelper      = Substitute.For <IHttpRequestMessageHelper>();
            _patchActionHttpTriggerService = Substitute.For <IPatchActionHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
            _patchActionHttpTriggerService.PatchResource(Arg.Any <string>(), _actionPatch).Returns(_action.ToString());
        }
 public void TearDown()
 {
     _validator = null;
 }
 public void SetUp()
 {
     _validator = new DeleteQueryValidator();
 }
示例#33
0
 public ValiateData()
 {
     this.validator = new Validate();
     database= new DataPersistance();
 }
示例#34
0
 public static bool IsValid(this IValidate obj)
 {
     return(obj.HasValue() && obj.Validate());
 }
示例#35
0
 public CampaignController(ICampaignRepository campaign, IValidate validate)
 {
     _campaign = campaign;
     _validate = validate;
 }
 public void SetUp()
 {
     _validator = new SelectQueryValidator();
 }
示例#37
0
 public void TearDown()
 {
     _columnValidator = null;
 }
示例#38
0
 public void SetUp()
 {
     _columnValidator = new ColumnValidator();
 }
 public OrValidationConverter(IValidate validate)
 {
     m_validate = validate;
 }
示例#40
0
 public SecurityController(IValidate validator, ISecurityHelper helper, IUserRepository userRepository)
 {
     _validator = validator;
     _helper = helper;
     _userRepository = userRepository;
 }
示例#41
0
 public UserController(IUserBLL userBLL, IValidate <UserModel> userModelValidationProvider, IPasswordHasher <UserModel> passwordHasher)
 {
     _userBLL = userBLL;
     _userModelValidationProvider = userModelValidationProvider;
     _passwordHasher = passwordHasher;
 }
 public ProspectListsController(IProspectListsRepository doNotCallListRepository, IValidate validate)
 {
     _prospectListsRepository = doNotCallListRepository;
     _validate = validate;
 }
 public void Register(IValidate validator)
 {
     _pipeline.Register(validator);
 }
示例#44
0
        public static async Task <HttpResponseMessage> RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "customers/{customerId}/ContactDetails/{contactid}")] HttpRequestMessage req, ILogger log,
                                                                string customerId, string contactid,
                                                                [Inject] IResourceHelper resourceHelper,
                                                                [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                                [Inject] IValidate validate,
                                                                [Inject] IPatchContactDetailsHttpTriggerService contactdetailsPatchService,
                                                                [Inject] IDocumentDBProvider provider)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function Patch Contact processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(contactid, out var contactGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(contactGuid));
            }

            ContactDetailsPatch contactdetailsPatchRequest;

            try
            {
                contactdetailsPatchRequest = await httpRequestMessageHelper.GetContactDetailsFromRequest <ContactDetailsPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (contactdetailsPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            contactdetailsPatchRequest.LastModifiedTouchpointId = touchpointId;

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var contactdetails = await contactdetailsPatchService.GetContactDetailsForCustomerAsync(customerGuid, contactGuid);

            if (contactdetails == null)
            {
                return(HttpResponseMessageHelper.NoContent(contactGuid));
            }

            var errors = validate.ValidateResource(contactdetailsPatchRequest, contactdetails, false);

            if (!string.IsNullOrEmpty(contactdetailsPatchRequest.EmailAddress))
            {
                var contacts = await provider.GetContactsByEmail(contactdetailsPatchRequest.EmailAddress);

                if (contacts != null)
                {
                    foreach (var contact in contacts)
                    {
                        var isReadOnly = await provider.DoesCustomerHaveATerminationDate(contact.CustomerId.GetValueOrDefault());

                        if (!isReadOnly && contact.CustomerId != contactdetails.CustomerId)
                        {
                            //if a customer that has the same email address is not readonly (has date of termination)
                            //then email address on the request cannot be used.
                            return(HttpResponseMessageHelper.Conflict());
                        }
                    }
                }
            }

            // Set Digital account properties so that contentenhancer can queue change on digital identity topic.
            var diaccount = await provider.GetIdentityForCustomerAsync(contactdetails.CustomerId.Value);

            if (diaccount != null)
            {
                if (contactdetailsPatchRequest.EmailAddress == string.Empty)
                {
                    if (errors == null)
                    {
                        errors = new List <System.ComponentModel.DataAnnotations.ValidationResult>();
                    }
                    errors.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Email Address cannot be removed because it is associated with a Digital Account", new List <string>()
                    {
                        "EmailAddress"
                    }));
                    return(HttpResponseMessageHelper.UnprocessableEntity(errors));
                }

                if (!string.IsNullOrEmpty(contactdetails.EmailAddress) && !string.IsNullOrEmpty(contactdetailsPatchRequest.EmailAddress) && contactdetails.EmailAddress?.ToLower() != contactdetailsPatchRequest.EmailAddress?.ToLower() && diaccount.IdentityStoreId.HasValue)
                {
                    contactdetails.SetDigitalAccountEmailChanged(contactdetailsPatchRequest.EmailAddress?.ToLower(), diaccount.IdentityStoreId.Value);
                }
            }

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var updatedContactDetails = await contactdetailsPatchService.UpdateAsync(contactdetails, contactdetailsPatchRequest);

            if (updatedContactDetails != null)
            {
                await contactdetailsPatchService.SendToServiceBusQueueAsync(updatedContactDetails, customerGuid, ApimURL);
            }

            return(updatedContactDetails == null?
                   HttpResponseMessageHelper.BadRequest(contactGuid) :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedContactDetails)));
        }
 public DomainCommandHandler(IBusPublisher busPublisher,
                             IMapper mapper, IRepository <TDomain, TKey> repo, IValidate <TDomain, TKey> validator = null, IValidateContext ctx = null) : base(busPublisher, mapper)
 {
     Repository = repo;
     Validator  = validator;
 }
示例#46
0
 public ValiateData(IValidate validate, IProcessMessage processor)
 {
     this.validator = validate;
     //this.processor = processor;
 }