Пример #1
0
        public async Task <CourseDetailDTO> GetCourseDetailAsync(int CourseId, CancellationToken cancellationToken)
        {
            CourseDetailDTO course = await NoTrackEntities.Include(c => c.CourseEpisods).Include(c => c.CourseStatus)
                                     .Include(c => c.CourseLevel).Include(c => c.CustomUser).Include(c => c.Keywordkeys)
                                     .Select(c => new CourseDetailDTO
            {
                CourseID          = c.Id,
                CourseDescription = c.CourseDescription,
                CourseLevelTitle  = c.CourseLevel.Title,
                CoursePrice       = c.CoursePrice,
                CourseStatusTitle = c.CourseStatus.Title,
                CourseTitle       = c.CourseTitle,
                CreateDate        = c.CreateDate,
                DemoFileName      = c.DemoFileName,
                Episods           = c.CourseEpisods.Select(e => new EpisodDTO {
                    EpisodeTime = e.EpisodeTime, EpisodID = e.Id, EpisodTitle = e.Title, IsFree = e.IsFree
                }).ToList(),
                Keywords = c.Keywordkeys.Select(k => new KeywordDTO {
                    Id = k.Id, Title = k.Title
                }).ToList(),
                ImageName       = c.ImageName,
                TeacherAvatar   = c.CustomUser.Avatar,
                TeacherID       = c.CustomUser.Id,
                TeacherUserName = c.CustomUser.ShowUserName,
                TotalEpisodTime = c.TotalEpisodTime,
                UpdateDate      = c.UpdateDate
            }).FirstOrDefaultAsync(c => c.CourseID == CourseId, cancellationToken);

            return(course);
        }
        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);
        }
Пример #3
0
        public async Task <PagedResult <Course> > GetPagedCourseAsync(string Title, bool IsDeleted, int Count, int CurrentNumber, CancellationToken cancellationToken,
                                                                      PriceStatusType PrisceStatusType = PriceStatusType.All, OrderStatusType orderStatusType = OrderStatusType.Default, int StartingPrice = 0, int EndOfPrice = 0,
                                                                      IEnumerable <int> SelectedGroup  = null, string KeyWordTitle = "")
        {
            PagedResult <Course> paged = new PagedResult <Course>();

            int ListCount = await NoTrackEntities.SmartWhere(Title, IsDeleted, SelectedGroup, StartingPrice, EndOfPrice, PrisceStatusType, KeyWordTitle).CountAsync(cancellationToken);

            IQueryable <Course> query = NoTrackEntities.SmartWhere(Title, IsDeleted, SelectedGroup, StartingPrice, EndOfPrice, PrisceStatusType, KeyWordTitle).SmartOrderByStatus(orderStatusType);

            paged.ListItem = await query.Skip((CurrentNumber - 1) *Count).Take(Count)
                             .AsNoTracking()
                             .ToListAsync(cancellationToken);

            paged.PageData.CurentItem  = CurrentNumber;
            paged.PageData.TotalItem   = ListCount;
            paged.PageData.ItemPerPage = Count;
            return(paged);
        }
Пример #4
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);
        }
Пример #6
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));
 }
Пример #7
0
 public async Task <DisCount> GetByTitle(string Title, CancellationToken cancellationToken)
 {
     return(await NoTrackEntities.FirstOrDefaultAsync(d => EF.Functions.Like(d.Title, $"{Title}"), cancellationToken));
 }
Пример #8
0
 public bool CheckExistEntity(string Title) => NoTrackEntities.Any(d => EF.Functions.Like(d.Title, $"{Title}"));
 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));
 }