public async Task <List <Transact> > GetWalletByUserIdAsync(Guid UserId, CancellationToken cancellationToken)
        {
            List <Transact> query = await NoTrackEntities.
                                    Where(t => t.CustomUserId == UserId).
                                    AsNoTracking().
                                    ToListAsync(cancellationToken);

            return(query);
        }
Пример #2
0
        public async Task <List <CourseGroupDTO> > GetGroupWithSubGroupAsync(CancellationToken cancellationToken, string GroupName, bool IsDeleted = false)
        {
            List <CourseGroupDTO> Entites = await NoTrackEntities.Where(cg => (string.IsNullOrEmpty(GroupName) || EF.Functions.Like(cg.Title, $"%{GroupName}%")) && cg.IsDeleted == IsDeleted)
                                            .Select(g => new CourseGroupDTO
            {
                Groups = g.Groups.Where(sg => sg.IsDeleted == IsDeleted && sg.ParentId == g.Id)
                         .Select(sg => new SubCourseGropDTO
                {
                    GroupTitle = sg.Title,
                    Id         = sg.Id
                }).ToList(),
                ParentId    = g.ParentId,
                ID          = g.Id,
                ParentTitle = g.Title
            })
                                            .ToListAsync(cancellationToken);

            return(Entites);
        }
        public async Task <PagedResult <CommentDTO> > GetPagedComment(int CourseId, int CurrentPageNumber, int TakeCount, CancellationToken cancellationToken)
        {
            PagedResult <CommentDTO> result = new PagedResult <CommentDTO>();
            int totalCount = await NoTrackEntities.CountAsync(c => c.CoourseId == CourseId && !c.IsDeleted, cancellationToken);

            result.ListItem = await NoTrackEntities.Where(c => c.CoourseId == CourseId && !c.IsDeleted)
                              .OrderByDescending(c => c.CreateTime)
                              .Skip((CurrentPageNumber - 1) * TakeCount)
                              .Select(c => new CommentDTO
            {
                Body       = c.Body,
                Name       = c.Name,
                UserAvatar = c.User.Avatar,
                CreateTime = c.CreateTime
            }).Take(TakeCount)
                              .ToListAsync(cancellationToken);

            result.PageData.CurentItem  = CurrentPageNumber;
            result.PageData.ItemPerPage = TakeCount;
            result.PageData.TotalItem   = totalCount;

            return(result);
        }
Пример #4
0
 public async Task <List <DisCount> > GetAllAsync(string DisCountname, CancellationToken cancellationToken)
 {
     return(await NoTrackEntities.Where(d => string.IsNullOrEmpty(DisCountname) || EF.Functions.Like(d.Title, $"%{DisCountname}%")).ToListAsync(cancellationToken));
 }
 public async Task <List <Keyword> > GetKeywordkeys(CancellationToken cancellationToken, string Keyword = null)
 {
     return(await NoTrackEntities.Where(k => string.IsNullOrEmpty(Keyword) || EF.Functions.Like(k.Title, $"%{Keyword}%")).ToListAsync(cancellationToken));
 }