コード例 #1
0
 public CourseValidator(
     IEnumerable <IValidatorConsumer <CourseModel> > validators,
     ITranslationService translationService, IProductCourseService productCourseService)
     : base(validators)
 {
     RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Admin.Courses.Course.Fields.Name.Required"));
     RuleFor(x => x.ProductId).MustAsync(async(x, y, context) =>
     {
         if (!string.IsNullOrEmpty(x.ProductId) && !string.IsNullOrEmpty(x.Id))
         {
             var course = await productCourseService.GetCourseByProductId(x.ProductId);
             if (course != null && course.Id != x.Id)
             {
                 return(false);
             }
         }
         if (!string.IsNullOrEmpty(x.ProductId) && string.IsNullOrEmpty(x.Id))
         {
             var course = await productCourseService.GetCourseByProductId(x.ProductId);
             if (course != null)
             {
                 return(false);
             }
         }
         return(true);
     }).WithMessage(translationService.GetResource("Admin.Courses.Course.Fields.ProductId.Assigned"));
 }
コード例 #2
0
 public CourseViewModelService(ICourseService courseService, ICourseLevelService courseLevelService, ICourseLessonService courseLessonService,
                               ICourseSubjectService courseSubjectService,
                               IUrlRecordService urlRecordService, IPictureService pictureService, ILanguageService languageService,
                               ILocalizationService localizationService, ICustomerActivityService customerActivityService, IProductCourseService productCourseService,
                               IServiceProvider serviceProvider,
                               SeoSettings seoSettings)
 {
     _courseService           = courseService;
     _courseLevelService      = courseLevelService;
     _courseLessonService     = courseLessonService;
     _courseSubjectService    = courseSubjectService;
     _urlRecordService        = urlRecordService;
     _pictureService          = pictureService;
     _languageService         = languageService;
     _localizationService     = localizationService;
     _customerActivityService = customerActivityService;
     _productCourseService    = productCourseService;
     _serviceProvider         = serviceProvider;
     _seoSettings             = seoSettings;
 }
コード例 #3
0
 public CourseViewModelService(ICourseService courseService, ICourseLevelService courseLevelService, ICourseLessonService courseLessonService,
                               ICourseSubjectService courseSubjectService,
                               ISlugService slugService, IPictureService pictureService, ILanguageService languageService,
                               ITranslationService translationService, ICustomerActivityService customerActivityService, IProductCourseService productCourseService,
                               IServiceProvider serviceProvider,
                               SeoSettings seoSettings)
 {
     _courseService           = courseService;
     _courseLevelService      = courseLevelService;
     _courseLessonService     = courseLessonService;
     _courseSubjectService    = courseSubjectService;
     _slugService             = slugService;
     _pictureService          = pictureService;
     _languageService         = languageService;
     _translationService      = translationService;
     _customerActivityService = customerActivityService;
     _productCourseService    = productCourseService;
     _serviceProvider         = serviceProvider;
     _seoSettings             = seoSettings;
 }
コード例 #4
0
 public CourseValidator(ILocalizationService localizationService, IProductCourseService productCourseService)
 {
     RuleFor(x => x.Name).NotEmpty().WithMessage(localizationService.GetResource("Admin.Courses.Course.Fields.Name.Required"));
     RuleFor(x => x.ProductId).MustAsync(async(x, y, context) =>
     {
         if (!string.IsNullOrEmpty(x.ProductId) && !string.IsNullOrEmpty(x.Id))
         {
             var course = await productCourseService.GetCourseByProductId(x.ProductId);
             if (course != null && course.Id != x.Id)
             {
                 return(false);
             }
         }
         if (!string.IsNullOrEmpty(x.ProductId) && string.IsNullOrEmpty(x.Id))
         {
             var course = await productCourseService.GetCourseByProductId(x.ProductId);
             if (course != null)
             {
                 return(false);
             }
         }
         return(true);
     }).WithMessage(localizationService.GetResource("Admin.Courses.Course.Fields.ProductId.Assigned"));
 }