public async Task <IEnumerable <PostInListDto> > GetAllAsync(PostSearchInput input) { try { return(await _postDalFacade.GetAllAsync(input)); } catch (Exception ex) { throw new Exception(ex.Message); } }
//TODO: Take all filters public async Task <IEnumerable <PostInListDto> > GetAllAsync(PostSearchInput filter) { try { return(await _context.Posts .Include(x => x.CreatorUser) .WhereIf(filter.CreationFrom.HasValue, x => x.CreationDate >= filter.CreationFrom) .WhereIf(filter.CreationTo.HasValue, x => x.CreationDate <= filter.CreationTo) .WhereIf(!String.IsNullOrEmpty(filter.PostName), x => x.Name.Contains(filter.PostName)) .Select(x => _mapper.Map <PostInListDto>(x)) .ToListAsync()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IActionResult> GetAll([FromBody] PostSearchInput input) { var result = await _postService.GetAllAsync(input); return(Json(result)); }