コード例 #1
0
        public InputGuideTownValidator(IGuideTownService GuideTownService)
        {
            _IGuideTownService = GuideTownService;

            RuleSet("AddGuideTown", () =>
            {
                RuleFor(m => m.CityId).SetValidator(new GuideIsCityIdExistPropertyValidator(_IGuideTownService));


                //Custom(m =>
                //{
                //    return !_ITownService.IsCityIdExist(m.CityId)
                //        ? new ValidationFailure("CityId", CityAndTown.CityIdNotExist)
                //        : null;
                //});
                CommonRules();
            });



            RuleSet("EditGuideTown", () =>
            {
                //Custom(m =>
                //{
                //    return !_ITownService.IsCityIdExist(m.CityId)
                //        ? new ValidationFailure("CityId", CityAndTown.CityIdNotExist)
                //        : null;
                //});
                RuleFor(m => m.Id).SetValidator(new GuideIsIdExistTownPropertyValidator(_IGuideTownService));

                //Custom(m =>
                //{
                //    return !_ITownService.IsIdExist(m.Id)
                //        ? new ValidationFailure("Id", CityAndTown.Id_failed)
                //        : null;
                //});

                CommonRules();
            });

            CommonRules();
        }
 public GuideIsIdExistTownPropertyValidator(IGuideTownService GuideTownService)
     : base(CityAndTown.Id_failed)
 {
     _IGuideTownService = GuideTownService;
 }
コード例 #3
0
 public AdminGuideCity_TownController(IGuideCityService IGuideCityService, IGuideTownService IGuideTownService, ApplicationUserManager userManager) : base(userManager)
 {
     _iGuideCityService = IGuideCityService;
     _iGuideTownService = IGuideTownService;
 }
 public GuideIsCityIdExistPropertyValidator(IGuideTownService GuideTownService)
     : base(CityAndTown.CityIdNotExist)
 {
     _IGuideTownService = GuideTownService;
 }