public async Task <IActionResult> GetAllPost() { var query = new GetAllPostQuery(); var result = await _mediator.Send(query); return(result != null?Success(result) : Error(new { info = "خطایی رخ داده است" })); }
public async Task <IActionResult> GetAll() { var query = new GetAllPostQuery(); var result = await _mediator.Send(query); return(Ok(result)); }
public async Task <IEnumerable <Post> > Handle(GetAllPostQuery request, CancellationToken cancellationToken) { string functionName = "GetAllPost:Get:"; Log.ForContext("Message", functionName) .ForContext("Error", "") .Information(functionName); return(await _read.GetAllPost()); }
public async Task <List <PostWithoutCommentsDto> > Handle(GetAllPostQuery request, CancellationToken cancellationToken) { var posts = await _postRepository.GetAll(); return(posts.Select(x => new PostWithoutCommentsDto { Content = x.Content, ModifiedDate = x.ModifiedDate, CreatedDate = x.CreatedDate, Title = x.Title, Id = x.Id }).ToList()); }
public async Task <IActionResult> GetAll([FromQuery] GetAllPostQuery query, [FromQuery] PaginationQuery paginationQuery) { var pagination = _mapper.Map <PaginationFilter>(paginationQuery); var filter = _mapper.Map <GetAllPostFilter>(query); var posts = await _postService.GetPostsAsync(filter, pagination); /* Commented due AutoMapper use * var postResponse = posts.Select(p => new PostResponse * { * Id = p.Id, * Name = p.Name, * UserId = p.UserId, * Tags = p.Tags.Select(t => new TagResponse {Name = t.TagName}) * }).ToList();*/ var postResponse = _mapper.Map <List <PostResponse> >(posts); var paginationResponse = PaginationHelper.CreatePaginatedResponse(_uriService, pagination, postResponse); return(Ok(paginationResponse)); }
public async Task <Response <IReadOnlyList <GetAllPostQueryResponse> > > Handle(GetAllPostQuery request, CancellationToken cancellationToken) { throw new System.NotImplementedException(); }