예제 #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
 private void _VMMapToBo(CourseItemContent bo, CourseItemContentVM boVM)
 {
     bo.Id          = boVM.Id;
     bo.Name        = boVM.Name;
     bo.SortCode    = boVM.SortCode;
     bo.Description = boVM.Description;
     bo.SecondTitle = boVM.SecondTitle;
     bo.HeadContent = boVM.HeadContent;
     bo.FootContent = boVM.FootContent;
 }
예제 #3
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);
        }
예제 #4
0
        private void _BoMapToVM(CourseItemContent bo, CourseItemContentVM boVM)
        {
            boVM.Id          = bo.Id;
            boVM.Name        = bo.Name;
            boVM.Description = bo.Description;
            boVM.SortCode    = bo.SortCode;
            boVM.SecondTitle = bo.SecondTitle;
            boVM.HeadContent = bo.HeadContent;
            boVM.FootContent = bo.FootContent;
            boVM.UpdateDate  = bo.UpdateDate.ToString("yyyy-MM-dd");

            if (bo.Editor != null)
            {
                boVM.CreatorUserID   = bo.Editor.Id.ToString();
                boVM.CreatorUserName = bo.Editor.UserName;
            }
        }
예제 #5
0
        public async Task <bool> SaveBo(CourseItemContentVM boVM)
        {
            var bo = _boRepository.GetSingle(boVM.Id);

            if (bo == null)
            {
                bo = new CourseItemContent();
            }

            _VMMapToBo(bo, boVM);

            if (!String.IsNullOrEmpty(boVM.CreatorUserID))
            {
                bo.Editor = await _userManager.FindByIdAsync(boVM.CreatorUserID);
            }

            var x = await _boRepository.AddOrEditAndSaveAsyn(bo);

            return(x);
        }
예제 #6
0
        public CourseItemContentVM GetVM(Guid boId)
        {
            var boVM = new CourseItemContentVM();
            // 初始化数据对象
            var bo = _boRepository.GetSingle(boId, z => z.Editor);

            if (bo == null)
            {
                bo         = new CourseItemContent();
                boVM.IsNew = true;
            }
            else
            {
                boVM.IsNew = false;
            }

            // 映射基本的属性值
            _BoMapToVM(bo, boVM);

            // 设置供前端下拉选项所需要的数据集合
            SetTypeItems(boVM);

            return(boVM);
        }
예제 #7
0
 public void SetTypeItems(CourseItemContentVM boVM)
 {
 }