Ejemplo n.º 1
0
 public async Task <IEnumerable <BlogInListDto> > GetAllAsync(BlogSearchInput input)
 {
     try
     {
         return(await _blogDalFacade.GetAllAsync(input));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 2
0
 //TODO: Take all filters
 public async Task <IEnumerable <BlogInListDto> > GetAllAsync(BlogSearchInput filter)
 {
     try
     {
         return(await _context.Blogs
                .Include(x => x.User)
                .Include(x => x.Rating)
                .Include(x => x.Posts)
                .WhereIf(filter.CreationFrom.HasValue, x => x.CreationDate >= filter.CreationFrom)
                .WhereIf(filter.CreationTo.HasValue, x => x.CreationDate <= filter.CreationTo)
                .WhereIf(!String.IsNullOrEmpty(filter.BlogName), x => x.Name.Contains(filter.BlogName))
                .Select(x => _mapper.Map <BlogInListDto>(x))
                .ToListAsync());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetAll([FromBody] BlogSearchInput input)
        {
            var result = await _blogService.GetAllAsync(input);

            return(Json(result));
        }