public async Task <PagedResponse <List <DiaryResponse> > > GetDiaryOfChildren(DiaryRequest request)
        {
            var response = new List <DiaryResponse>();
            var child    = await _unitOfWork.ChildInfoRepository.FirstAsync(x => x.Id == request.ChildId);

            if (child is null)
            {
                return(new PagedResponse <List <DiaryResponse> >(null, $"Không tìm thấy bé \'{request.ChildId}\'."));
            }

            var diary = await _unitOfWork.DiaryRepository.GetPagedReponseAsync(request.PageNumber, request.PageSize,
                                                                               filter : x => x.ChildId == request.ChildId && x.DelFlag == false,
                                                                               orderBy : x => x.OrderByDescending(o => o.CreatedTime));

            if (diary.Count == 0)
            {
                return(new PagedResponse <List <DiaryResponse> >(null, $"Bé {child.FullName} chưa có nhật ký nào!"));
            }

            response = _mapper.Map <List <DiaryResponse> >(diary);
            var total = await _unitOfWork.DiaryRepository.CountAsync(x => x.ChildId == request.ChildId && x.DelFlag == false);

            return(new PagedResponse <List <DiaryResponse> >(response, request.PageNumber, request.PageSize, total));
        }
 public async Task <IActionResult> GetDiaryOfChildren([FromQuery] DiaryRequest request)
 {
     return(Ok(await _diaryService.GetDiaryOfChildren(request)));
 }