public PersistenceUnitOfWork(AppDbContext appDbContext, IPostRepositoryAsync post, IRepositoryAsync <Comment> comment, ICategoryRepositoryAsync category, ITagRepositoryAsync tag) { _dbContext = appDbContext; Linq2Db = _dbContext.CreateLinqToDbConnection(); Post = post; Comment = comment; Category = category; Tag = tag; }
public CreatePostCommandValidator(IPostRepositoryAsync postRepository) { this._postRepository = postRepository; //RuleForEach(p => p.Locales).ChildRules(locales => //{ // locales.RuleFor(t => t.Title).NotEmpty().WithMessage("{PropertyName} is required."); //}); RuleFor(p => p.Locales) .Must(x => x.Count > 0).WithMessage("at least 1 language specific data is required."); RuleForEach(p => p.Locales) .SetValidator(new PostLocaleValidator(_postRepository)); }
public PostLocaleValidator(IPostRepositoryAsync postRepository) { this._postRepository = postRepository; RuleFor(p => p.Title) .NotEmpty().WithMessage("{PropertyName} is required.") .NotNull() .MaximumLength(25).WithMessage("{PropertyName} must not exceed 50 characters.") .MustAsync(IsUniqueTitle).WithMessage("{PropertyName} already exists."); RuleFor(p => p.Content) .NotEmpty().WithMessage("{PropertyName} is required.") .NotNull() .MaximumLength(5000).WithMessage("{PropertyName} must not exceed 50 characters."); RuleFor(p => p.CultureId) .NotNull() .GreaterThan(0); }
public async Task SetUp() { var posts = new List <Post> { new Post { Id = 1, Title = "First Post", Slug = "first-post", Summary = "This is a first post", Content = "This is a big content" }, new Post { Id = 2, Title = "second Post", Slug = "second-post", Summary = "This is a second post", Content = "This is a big content" }, new Post { Id = 3, Title = "third Post", Slug = "third-post", Summary = "This is a third post", Content = "This is a big content" } }; var dbContext = await GetInMemoryDbContext.GetMemoryContext(); await dbContext.Posts.AddRangeAsync(posts); await dbContext.SaveChangesAsync(); _postRepositoryAsync = new PostRepositoryAsync(dbContext); }
//private readonly IMediator _mediator; public SearchPostsQueryHandler(IPostRepositoryAsync postRepository, IMapper mapper /*, IMediator mediator*/) { _postRepository = postRepository; _mapper = mapper; //_mediator = mediator; }
public PostVisitedHandler(ILogger <PostVisitedHandler> logger, IPostRepositoryAsync postRepository) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _postRepository = postRepository ?? throw new ArgumentNullException(nameof(postRepository)); }
public UpdatePostCommandHandler(IPostRepositoryAsync productRepository) { _postRepository = productRepository; }
public PostAsynService(IPostRepositoryAsync postRepository, IUnitOfWorkAsync unitOfWork) : base(postRepository, unitOfWork) { this._unitOfWork = unitOfWork; this._postRepository = postRepository; }
public CreatePostCommandHandler(IPostRepositoryAsync postRepository, IMapper mapper, IMediator mediator) { _postRepository = postRepository; _mapper = mapper; _mediator = mediator ?? throw new ArgumentNullException($"{nameof(mediator)} is null"); }
public DeletePostByIdCommandHandler(IPostRepositoryAsync postRepository) { _postRepository = postRepository; }
public PostAsynService(IPostRepositoryAsync postRepository, IUnitOfWorkAsync unitOfWork) : base(postRepository, unitOfWork) { }