コード例 #1
0
        public void AddOrUpdate(TContext context, TEntity entity)
        {
            TValidator validator        = new TValidator();
            var        validationResult = ValidatorTool.Validate(validator, entity);

            if (validationResult)
            {
                context.Set <TEntity>().AddOrUpdate(entity);
            }
        }
コード例 #2
0
        public bool AddorUpdate(TContext context, TEntity entity)
        {
            TValidator validator       = new TValidator();
            var        validatorResult = ValidatorTool.Validate(validator, entity);

            if (validatorResult)
            {
                context.Set <TEntity>().AddOrUpdate(entity);
            }

            return(validatorResult);
        }
コード例 #3
0
        public bool AddOrUpdate(TContext context, TEntity entity)
        //eklemeguncelleme metodu
        {
            TValidator validator        = new  TValidator();
            var        validationResult = ValidatorTool.Validate(validator, entity);

            //validationresult değişkenine bool tipinde dönen validate sonucu atandı. entity den gelen sonuc ile eşitle
            if (validationResult)
            {
                context.Set <TEntity>().AddOrUpdate(entity);
            }

            return(validationResult);
        }
コード例 #4
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator = (IValidator)Activator.CreateInstance(_validatorType);

            if (_validatorType.BaseType != null)
            {
                var entityType = _validatorType.BaseType.GetGenericArguments()[0];
                var entities   = args.Arguments.Where(t => t.GetType() == entityType);

                foreach (var entity in entities)
                {
                    ValidatorTool.Validate(validator, entity);
                }
            }
        }