示例#1
0
        public async Task <bool> SaveCourseItemContent(CourseItemContentVM boVM)
        {
            var contentFactory = new CourseItemContentVMService(_userManager, _courseItemContentRepository, _boRepository);
            var saveStatus     = await contentFactory.SaveBo(boVM);

            return(saveStatus);
        }
示例#2
0
        /// <summary>
        /// 根据传入 CourseItem 的 Id 获取 CourseItemContentVM
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <CourseItemContentVM> GetCourseItemContentVM(Guid id)
        {
            // 初始化数据对象
            var bo             = _boRepository.GetSingle(id, x => x.ParentCourseItem, y => y.Course, w => w.CourseItemContent, z => z.Creator);
            var content        = bo.CourseItemContent;
            var contentFactory = new CourseItemContentVMService(_userManager, _courseItemContentRepository, _boRepository);
            var contentVM      = contentFactory.GetVM(content.Id);

            if (contentVM == null)
            {
                contentVM = new CourseItemContentVM();
            }
            else
            {
                contentVM.CourseID       = bo.Course.Id.ToString();
                contentVM.CourseName     = bo.Course.Name;
                contentVM.CourseItemID   = bo.Id.ToString();
                contentVM.CourseItemName = bo.Name;
            }

            // 处理附件
            var video = _businessVideoService.GetSingleBy(x => x.RelevanceObjectID == content.Id);

            if (video == null)
            {
                video = new BusinessVideo();
            }
            contentVM.Video = new BusinessVideoVM(video);

            var images = await _businessImageService.GetAllAsyn(x => x.RelevanceObjectID == content.Id);

            contentVM.ImageCollection = new List <BusinessImageVM>();
            foreach (var item in images)
            {
                contentVM.ImageCollection.Add(new BusinessImageVM(item));
            }

            var files = await _businessFileService.GetAllAsyn(x => x.RelevanceObjectID == content.Id);

            contentVM.FileCollection = new List <BusinessFileVM>();
            foreach (var item in files)
            {
                contentVM.FileCollection.Add(new BusinessFileVM(item));
            }

            return(contentVM);
        }
示例#3
0
        /// <summary>
        /// 根据传入 CourseItemContent 的 Id 获取 CourseItemContentVM
        /// </summary>
        /// <returns></returns>
        public async Task <CourseItemContentVM> DeletCourseItemContentFile(Guid id, Guid businessFileId)
        {
            _businessFileService.DeleteAndSave(businessFileId);

            var contentFactory = new CourseItemContentVMService(_userManager, _courseItemContentRepository, _boRepository);
            var contentVM      = contentFactory.GetVM(id);
            var bo             = _boRepository.GetAllIncluding(x => x.ParentCourseItem, y => y.Course, w => w.CourseItemContent, z => z.Creator).Where(x => x.CourseItemContent.Id == id).FirstOrDefault();

            contentVM.CourseID       = bo.Course.Id.ToString();
            contentVM.CourseName     = bo.Course.Name;
            contentVM.CourseItemID   = bo.Id.ToString();
            contentVM.CourseItemName = bo.Name;

            // 处理附件
            var video = _businessVideoService.GetSingleBy(x => x.RelevanceObjectID == id);

            if (video == null)
            {
                video = new BusinessVideo();
            }
            contentVM.Video = new BusinessVideoVM(video);

            var images = await _businessImageService.GetAllAsyn(x => x.RelevanceObjectID == id);

            contentVM.ImageCollection = new List <BusinessImageVM>();
            foreach (var item in images)
            {
                contentVM.ImageCollection.Add(new BusinessImageVM(item));
            }

            var files = await _businessFileService.GetAllAsyn(x => x.RelevanceObjectID == id);

            contentVM.FileCollection = new List <BusinessFileVM>();
            foreach (var item in files)
            {
                contentVM.FileCollection.Add(new BusinessFileVM(item));
            }

            return(contentVM);
        }