Exemplo n.º 1
0
 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));
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 6
0
 public PostVisitedHandler(ILogger <PostVisitedHandler> logger, IPostRepositoryAsync postRepository)
 {
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
     _postRepository = postRepository ?? throw new ArgumentNullException(nameof(postRepository));
 }
Exemplo n.º 7
0
 public UpdatePostCommandHandler(IPostRepositoryAsync productRepository)
 {
     _postRepository = productRepository;
 }
Exemplo n.º 8
0
 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");
 }
Exemplo n.º 10
0
 public DeletePostByIdCommandHandler(IPostRepositoryAsync postRepository)
 {
     _postRepository = postRepository;
 }
Exemplo n.º 11
0
 public PostAsynService(IPostRepositoryAsync postRepository, IUnitOfWorkAsync unitOfWork) : base(postRepository,
                                                                                                 unitOfWork)
 {
 }