/// <summary>
        /// Validates the current object
        /// </summary>
        /// <param name="objToValidate"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        protected bool Validate(IValidationModel objToValidate, string nullArgMessage)
        {
            if (Channel.IsClosed)
            {
                Logger.Error("Exchange Channel is closed");
                throw new ServiceException("Channel is closed");
            }

            string errormsg = "";

            if (objToValidate == null)
            {
                errormsg = $"Please supply a valid {nullArgMessage}";
                Logger.Warn(errormsg);
                throw new ArgumentNullException(errormsg);
            }

            if (!objToValidate.TryValidate(out errormsg))
            {
                Logger.Warn(errormsg);
                throw new ValidationException(errormsg);
            }

            return(true);
        }
Beispiel #2
0
        private void BindValidation(PropertyModel propertyModel)
        {
            Type typeOfModelToValidate = propertyModel.ReferencedModelType;

            foreach (object attribute in propertyModel.Attributes)
            {
                IPropertyAttribute baseAttribute = attribute as BasePropertyAttribute;
                if (baseAttribute != null)
                {
                    IValidationModel validationModel = MakeValidationModel(propertyModel, baseAttribute);
                    validationCollection[typeOfModelToValidate].Add(validationModel);
                }
            }
        }
Beispiel #3
0
 public MatchServiceValidation(IValidationModel <Match> matchValid, IBoardGameDbContext context)
 {
     this.matchValidation = matchValid;
     this.context         = context;
 }