public TimeTable Update(TimeTable entity)
 {
     ValidatorTool.FluentValidate(new TimeTableValidator(), entity);
     TimeTableLecturerScheduleClashValidator(entity);
     TimeTableIntakeScheduleClashValidator(entity);
     TimeTableClassRoomScheduleClashValidator(entity);
     return(_timeTableDal.Update(entity));
 }
Exemple #2
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);
            }
        }
        public IntakeCourse Insert(IntakeCourse entity)
        {
            ValidatorTool.FluentValidate(new IntakeCourseValidator(), entity);
            var intakeCourse = _intakeCourseDal.Get(x => (x.IntakeID == entity.IntakeID) || (x.IntakeID == entity.IntakeID && x.CourseID == entity.CourseID) && x.IsIntakeCourseActive == true);

            if (intakeCourse != null)
            {
                throw new DataExistException("Intake Course Already Exists!");
            }
            return(_intakeCourseDal.Insert(entity));
        }
        protected override void OnBefore(IInvocation invocation)
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            var entities   = invocation.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
Exemple #5
0
        public override void OnEntry(MethodExecutionArgs args /*çalışan methodla ilgili bilgi verir*/) //methoda girdiğinde
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);                     //Gelen validaton clasının tipini(insancesini) almak
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];                         //gelen classın generic nesnesini yakalar. ProductValidatior içinde sadece bir tane olduğu için 0 indisli aldık.
            var entites    = args.Arguments.Where(t => t.GetType() == entityType);                     //çalışan methodtaki parametreleri yakalar dizi olarak atar

            foreach (var entity in entites)
            {
                ValidatorTool.FluentValidate(validator, entity); //gelen class ve entity core katmanında yazdığımız validatortool içindeki methoda gönderdik
            }
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator  = (IValidator)Activator.CreateInstance(_validationType); //Ivalidator tipinde bir instance yarattık.
            var entityType = _validationType.BaseType.GetGenericArguments()[0];     //Validatior aracımızın AbstractValidator<x> gereneric metondundaki X classa ulaştık.//getgenericargument array döner.
            var entities   = args.Arguments.Where(e => e.GetType() == entityType);  //Hedef metodun parametrelerinden entityType olanları entities lere ekle

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            var entities   = args.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
Exemple #8
0
        public Subject Insert(Subject entity)
        {
            ValidatorTool.FluentValidate(new SubjectValidator(), entity);
            var isExist = _subjectDal.Get(x => x.SubjectName == entity.SubjectName);

            if (isExist != null)
            {
                throw new DataExistException("A Subject with the same name already exists.");
            }

            return(_subjectDal.Insert(entity));
        }
Exemple #9
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            // base.OnEntry(args); // Method girdiğimizde doğrulama yapsın
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];     // burada Product nesnesi ile çalışacağımı biliyorum
            var entities   = args.Arguments.Where(t => t.GetType() == entityType); // Product Managerde çaliştiğim metodun parametreleri gezip tipi product olanları yakalanıyorum

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
Exemple #10
0
        public Course Update(Course entity)
        {
            ValidatorTool.FluentValidate(new CourseValidator(), entity);
            var hasCourse = _intakeCourseService.GetAll().FirstOrDefault(x => x.CourseID == entity.CourseID && x.IsIntakeCourseActive == true);

            if (hasCourse != null)
            {
                throw new DataUsedException("You cannot modify a course that is in use by an intake.");
            }
            entity.IsCourseActive = true;
            return(_courseDal.Update(entity));
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            //Activator.CreateInstance metodu tipi belli olmayan tiplerin tipini öğrenmeye yarar :)
            var validator  = (IValidator)Activator.CreateInstance(_validatorType); //burda gelen tipi new 'liyoruz. yani ProductValidator validator=new ProductValidator(); gibi
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];     //ProductValidator generic  base classının ilk parametresini aldık .yani ProductValidator : AbstractValidator<Product> burdaki Product classına eriştik.
            var entities   = args.Arguments.Where(t => t.GetType() == entityType); //args dediğimiz şey bu aspect attributeünün bağlı oldu Add() metodunun parametreleri anlamına gelir.yani public void Add(Product product) burdaki product nesnesine karşlık gelir.

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
Exemple #12
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);
        }
Exemple #13
0
        public Course Insert(Course entity)
        {
            ValidatorTool.FluentValidate(new CourseValidator(), entity);
            var hasCourse = GetAll().FirstOrDefault(x => x.CourseName == entity.CourseName && x.IsCourseActive == true);

            if (hasCourse != null)
            {
                throw new DataExistException("A course with the same name already exists.");
            }
            entity.IsCourseActive = true;
            return(_courseDal.Insert(entity));
        }
        public override void OnEntry(MethodExecutionArgs args) //methoda girildiği an, fluentvalidationu kullanan kimse(ProductManager), methodun girişinde bu aspect devreye girecektir
        {
            //Ne ile validate edeceğimin bilgisi var ama instanceı yok
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];     //Basetype: abstractvalidator, onun içinde product type var onu al
            var entities   = args.Arguments.Where(t => t.GetType() == entityType); //Çalıştığım metotun parametrelerini gez ve tipi product olanları yakala

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator = (IValidator)Activator.CreateInstance(_validatorType);
            //validation tools abstack product olan yer
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            //validate edilicek yer Product product tipi olanları getir
            var entities = args.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
        //Fonksiyona girer girmez çalışır
        public override void OnEntry(MethodExecutionArgs args)//Args çalıştırılan metodla ilgili bilgi alımını sağlar.
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            //Tüm argumanları gez veri tipini al
            var entities = args.Arguments.Where(t => t.GetType() == entityType);

            //Alınan argumanları foreach ile gez
            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);
            }
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator  = (IValidator)Activator.CreateInstance(_ValidatorType);
            var entityType = _ValidatorType.BaseType.GetGenericArguments()[0];   //ProductValidator de
            //base degerini alıyoruz
            var entities = args.Arguments.Where(t => t.GetType() == entityType); //burda degeri alıyoruz

            //degeri entitie eşitliyoruz //çalışıgımız metodda parametlerini geziyoruz burda
            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidate(validator, entity);//degerleri geziyoruz yazdıgımız metoda gonderiyoruz
            }
        }
Exemple #18
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);
        }
Exemple #19
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            var entities   = args.Arguments.Where(t => t.GetType() == entityType);



            foreach (var entity in entities)
            {
                //object bir nesneyi IValidationContext Türüne çevirmek için ValidationContext Generic Sınıfı kullanıldı.
                var context = new ValidationContext <object>(entity);

                ValidatorTool.FluentValidate(validator, context);
            }
        }
        //methoda girdiğinde
        public override void OnEntry(MethodExecutionArgs args)
        {
            //depenceny injection ile hangi validatin gönderildiğini bulduk
            //onun instance oluşturduk
            var validator = (IValidator)Activator.CreateInstance(_validatorType);
            //oluşturulan instance ın hangi entity kullandığını bulduk
            var entityType = _validatorType.BaseType.GetGenericArguments()[0];
            //validate edilecek entitileri buluyoruz.
            //args çalışılacak metodla ilgili bilgilere ulaşmaya yarar
            //metoddaki parametleri geziyorum ve tipi benim validate edeçeğim entitiyi buluyorum
            var entities = args.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool.FluentValidation(validator, entity);
            }
        }
Exemple #21
0
        public Intake Insert(Intake entity)
        {
            ValidatorTool.FluentValidate(new IntakeValidator(), entity);
            var hasIntake = GetAll().FirstOrDefault(x => x.IntakeID == entity.IntakeID);

            if (hasIntake != null && hasIntake.IsIntakeActive == false)
            {
                hasIntake.IsIntakeActive = true;
                return(Update(hasIntake));
            }
            else if (hasIntake != null && hasIntake.IsIntakeActive == true)
            {
                throw new DataExistException("This intake is already being used.");
            }

            return(_intakeDal.Insert(entity));
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator = (IValidator)Activator.CreateInstance(_validatorType);

            var entityType = _validatorType.BaseType.GetGenericArguments()[0];

            var entities = args.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool tool = new ValidatorTool(_hostingEnvironment);

                tool.FluentValidate(validator, entity);
            }

            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert("onentry", Layer.Admin);
        }
        protected override void OnBefore(IInvocation invocation)
        {
            if (!typeof(IValidator).IsAssignableFrom(_validatorType))
            {
                throw new Exception("Invalid Validator Type");
            }

            var validator = (IValidator)Activator.CreateInstance(_validatorType);

            if (_validatorType.BaseType != null)
            {
                var entityType = _validatorType.BaseType.GetGenericArguments()[0];
                var entities   = invocation.Arguments.Where(x => x.GetType() == entityType).ToList();
                foreach (var entity in entities)
                {
                    ValidatorTool.FluentValidate(validator, entity);
                }
            }
        }
Exemple #24
0
 public Subject Update(Subject entity)
 {
     ValidatorTool.FluentValidate(new SubjectValidator(), entity);
     return(_subjectDal.Update(entity));
 }
Exemple #25
0
 public void Update(Customer customer)
 {
     ValidatorTool.FluentValidate(new CustomerValidator(), customer);
     _customerDal.Update(customer);
 }
Exemple #26
0
 public Product Add(Product product)
 {
     ValidatorTool.FluentValidate(new ProductValidator(), product);
     return(_productDal.Add(product));
 }
Exemple #27
0
 public Product Update(Product product)
 {
     ValidatorTool.FluentValidate(new ProductValidatior(), product);
     return(_productDal.Update(product));
 }