Ejemplo n.º 1
0
        public async Task <BaseResponseDto <List <PostDto> > > GetClassPostsAsync([FromRoute] int Classid)
        {
            GetClassPostsRequest getClassPostsRequest = new GetClassPostsRequest();

            getClassPostsRequest.Classid = Classid;
            BaseResponseDto <List <PostDto> > response = await _mediator.Send(getClassPostsRequest);

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <BaseResponseDto <List <PostDto> > > Handle(GetClassPostsRequest request, CancellationToken cancellationToken)
        {
            BaseResponseDto <List <PostDto> > response = new BaseResponseDto <List <PostDto> >();

            try
            {
                var result = _repositoryWrapper.Post.Where(p => p.Classid == request.Classid)
                             .Include(p => p.Class)
                             .Include(p => p.User)
                             .Select(p => new PostDto(p));
                if (result != null)
                {
                    response.Data = await result.ToListAsync();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.InnerException.Message);
                response.Errors.Add(ex.InnerException.Message);
                response.Errors.Add("Üye oluşturulurken bir hata oluştu.");
            }
            return(response);
        }