Example #1
0
        /// <summary>
        /// 返回全部业务对象对应的视图模型,返回的视图模型根据要求做了层次化处理
        /// </summary>
        /// <param name="boService"></param>
        /// <returns></returns>
        public async Task <List <ArticleTypeVM> > GetboVMCollectionAsyn()
        {
            var boCollection = await _boRepository.GetAllIncludingAsyn(x => x.ParentType);

            var boVMCollection = new List <ArticleTypeVM>();
            var counter        = 0;

            foreach (var bo in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = GetVM(bo);
                boVM.OrderNumber = (++counter).ToString();
                boVMCollection.Add(boVM);
            }

            #region 为部门数据呈现处理名称缩进
            var parentTypeItems = SelfReferentialItemFactory <ArticleType> .GetCollection(boCollection.ToList(), true);

            foreach (var item in parentTypeItems)
            {
                var dID  = Guid.Parse(item.ID);
                var dept = boVMCollection.FirstOrDefault(x => x.Id == dID);
                dept.Name = item.DisplayName;
            }
            #endregion

            return(boVMCollection);
        }
Example #2
0
        public async Task <IActionResult> CreateOrEdit(Guid id)
        {
            var isNew = false;
            var bo    = await _BoRepository.GetSingleAsyn(id, x => x.Department);

            if (bo == null)
            {
                bo             = new Person();
                bo.Name        = "";
                bo.Email       = "";
                bo.Mobile      = "";
                bo.Description = "";
                bo.SortCode    = "";
                isNew          = true;
            }

            var boVM = new PersonVM(bo);

            boVM.IsNew = isNew;

            #region 创建供归属部门选择器使用的元素集合
            var depts       = _BoRepository.EntitiesContext.Departments.ToList();
            var selectItems = SelfReferentialItemFactory <Department> .GetCollection(depts, true);

            boVM.ParentItemCollection = selectItems;
            #endregion

            return(View("../../Views/BusinessOrganization/Person/CreateOrEdit", boVM));
        }
Example #3
0
        public async Task <IActionResult> List(string keyword)
        {
            var boCollection = await _BoRepository.GetAllAsyn();

            var boVMCollection = new List <DepartmentVM>();

            var couter = 0;

            foreach (var item in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = new DepartmentVM(item);
                boVM.OrderNumber = (++couter).ToString();
                boVMCollection.Add(boVM);
            }

            #region 为部门数据呈现处理名称缩进
            var deptItems = SelfReferentialItemFactory <Department> .GetCollection(boCollection.ToList(), true);

            foreach (var item in deptItems)
            {
                var dID  = Guid.Parse(item.ID);
                var dept = boVMCollection.FirstOrDefault(x => x.ID == dID);
                dept.Name = item.DisplayName;
            }
            #endregion

            return(PartialView("../../Views/BusinessOrganization/Department/_List", boVMCollection));
        }
Example #4
0
        /// <summary>
        /// 返回全部业务对象对应的视图模型,返回的视图模型根据要求做了层次化处理
        /// </summary>
        /// <param name="boService"></param>
        /// <returns></returns>
        public async Task <List <GradeAndClassVM> > GetboVMCollectionAsyn()
        {
            var boCollection = await _boRepository.GetAllIncludingAsyn(role => role.ApplicationRole, dept => dept.ParentDepartment);

            var boVMCollection = new List <GradeAndClassVM>();
            var counter        = 0;

            foreach (var bo in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = await GetVM(bo);

                boVM.OrderNumber = (++counter).ToString();
                boVMCollection.Add(boVM);
            }

            #region 为部门数据呈现处理名称缩进
            var deptItems = SelfReferentialItemFactory <GradeAndClass> .GetCollection(boCollection.ToList(), true);

            foreach (var item in deptItems)
            {
                var dID  = Guid.Parse(item.ID);
                var dept = boVMCollection.FirstOrDefault(x => x.Id == dID);
                dept.Name = item.DisplayName;
            }
            #endregion

            return(boVMCollection);
        }
Example #5
0
        public async Task <List <TViewModel> > GetBoVMCollectionWithHierarchicalStyleAsyn()
        {
            var boCollection = await _entityRepository.GetBoCollectionAsyn();

            var selfReferentialItemCollection = SelfReferentialItemFactory <TEntity> .GetCollection(boCollection.ToList(), true);

            var boVMCollection = new List <TViewModel>();
            int count          = 0;

            foreach (var item in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = new TViewModel();
                item.MapToViewModel <TEntity, TViewModel>(boVM);
                boVM.OrderNumber = (++count).ToString();
                var sItem = selfReferentialItemCollection.FirstOrDefault(x => x.ID == item.ID.ToString());
                if (sItem != null)
                {
                    boVM.Name = sItem.DisplayName;
                }

                boVMCollection.Add(boVM);
            }

            return(boVMCollection);
        }
Example #6
0
        /// <summary>
        /// 设置与传入的视图模型相关的关联元素的集合值
        /// </summary>
        /// <param name="boVM"></param>
        /// <param name="courseID"></param>
        /// <returns></returns>
        public async Task SetTypeItems(CourseItemVM boVM, Guid courseID)
        {
            var boCollection = await _boRepository.GetAllAsyn(y => y.Course.Id == courseID);

            boVM.ParentCourseItemCollection = SelfReferentialItemFactory <CourseItem> .GetCollection(boCollection.OrderBy(x => x.SortCode).ToList(), true);

            boVM.CourseItemCollection = PlainFacadeItemFactory <Course> .Get(_courseRepository);
        }
        /// <summary>
        /// 设置用于前端页面需要的关联数据选项
        /// </summary>
        public void SetRelevanceItems(DepartmentVM boVM)
        {
            boVM.DepartmentTypeItemCollection = PlainFacadeItemFactory <Department> .GetByEnum(boVM.DepartmentType);

            boVM.ParentDepartmentItemCollection = SelfReferentialItemFactory <Department> .GetCollection(_boRepository, true);

            boVM.OrganizationItemCollection = PlainFacadeItemFactory <Organ> .Get(_orgRepository);

            boVM.ApplicationRoleItemCollection = _GetApplicationRoleItemCollection(_roleManager.Roles.ToList());
        }
Example #8
0
        public virtual async Task <List <TreeNodeForBootStrapTreeView> > GetTreeViewNodeForBootStrapTreeViewCollectionAsyn <SelfReferentialEntity>(Expression <Func <SelfReferentialEntity, object> > includeProperty) where SelfReferentialEntity : class, IEntity, new()
        {
            // 提取 <SelfReferentialEntity> 数据集合
            var selfReferentialEntityCollection = await _entityRepository.EntitiesContext.Set <SelfReferentialEntity>().Include(includeProperty).OrderBy(x => x.SortCode).ToListAsync();

            // 转换为 SelfReferentialItem 集合
            var selfReferentialItemCollection = SelfReferentialItemFactory <SelfReferentialEntity> .GetCollection(selfReferentialEntityCollection, false);

            // 构建树节点集合
            var result = TreeViewFactoryForBootSrapTreeView.GetTreeNodes(selfReferentialItemCollection);

            return(result);
        }
Example #9
0
        /// <summary>
        /// 根据课程 Id 返回课程相关的课程单元视图模型的对象集合
        /// </summary>
        /// <param name="courseId"></param>
        /// <returns></returns>
        public async Task <List <CourseItemVM> > GetboVMCollectionAsyn(Guid courseId)
        {
            var course = _courseRepository.GetSingle(courseId);

            if (course == null)
            {
                course = _courseRepository.GetAll().FirstOrDefault();
                if (course != null)
                {
                    courseId = course.Id;
                }
            }

            var boCollection = await _boRepository.GetAllAsyn(x => x.Course.Id == courseId);

            var boVMCollection = new List <CourseItemVM>();
            var counter        = 0;

            foreach (var bo in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = await GetVM(bo.Id);

                boVM.OrderNumber = (++counter).ToString();
                boVMCollection.Add(boVM);
            }

            // 做层次化处理
            var tempItems = SelfReferentialItemFactory <CourseItem> .GetCollection(boCollection.ToList(), true);

            foreach (var item in tempItems)
            {
                var dID  = Guid.Parse(item.ID);
                var boVM = boVMCollection.FirstOrDefault(x => x.Id == dID);
                boVM.Name = item.DisplayName;
            }

            return(boVMCollection);
        }
Example #10
0
        public async Task <IActionResult> CreateOrEdit(Guid id)
        {
            var isNew = false;
            var bo    = await _BoRepository.GetSingleAsyn(id);

            if (bo != null && bo.ParentDepartment == null)
            {
                var AllAsyn = _BoRepository.GetAllAsyn();
                foreach (var item in AllAsyn.Result)
                {
                    if (item.ID == id)
                    {
                        bo.ParentDepartment = item.ParentDepartment;
                    }
                }
            }
            if (bo == null)
            {
                bo             = new Department();
                bo.Name        = "";
                bo.Description = "";
                bo.SortCode    = "";
                isNew          = true;
            }

            var boVM = new DepartmentVM(bo);

            boVM.IsNew = isNew;

            #region 创建供归属部门选择器使用的元素集合
            var depts       = _BoRepository.EntitiesContext.Departments.ToList();
            var selectItems = SelfReferentialItemFactory <Department> .GetCollection(depts, true);

            boVM.ParentItemCollection = selectItems;
            #endregion

            return(PartialView("../../Views/BusinessOrganization/Department/_CreateOrEdit", boVM));
        }
Example #11
0
        public async Task <List <TViewModel> > GetBoVMCollectionWithHierarchicalStyleAsyn(ListSinglePageParameter listPageParameter, Expression <Func <TEntity, bool> > navigatorPredicate, Expression <Func <TEntity, object> > includeProperty)
        {
            var boCollection = await _entityRepository.GetBoCollectionAsyn(listPageParameter, navigatorPredicate, includeProperty);

            var selfReferentialItemCollection = SelfReferentialItemFactory <TEntity> .GetCollection(boCollection.ToList(), true);

            var boVMCollection = new List <TViewModel>();
            int count          = 0;

            foreach (var item in boCollection.OrderBy(x => x.SortCode))
            {
                var boVM = new TViewModel();
                item.MapToViewModel <TEntity, TViewModel>(boVM);
                boVM.OrderNumber = (++count).ToString();
                var sItem = selfReferentialItemCollection.FirstOrDefault(x => x.ID == item.ID.ToString());
                if (sItem != null)
                {
                    boVM.Name = sItem.DisplayName;
                }
                boVMCollection.Add(boVM);
            }

            return(boVMCollection);
        }
Example #12
0
 /// <summary>
 /// 设置用于前端页面需要的关联数据选项
 /// </summary>
 public void SetRelevanceItems(ArticleTypeVM boVM)
 {
     boVM.ParentItemCollection = SelfReferentialItemFactory <ArticleType> .GetCollection(_boRepository, true);
 }
Example #13
0
        /// <summary>
        /// 设置用于前端页面需要的关联数据选项
        /// </summary>
        public void SetRelevanceItems(GradeAndClassVM boVM)
        {
            boVM.ParentDepartmentItemCollection = SelfReferentialItemFactory <GradeAndClass> .GetCollection(_boRepository, true);

            boVM.ApplicationRoleItemCollection = _GetApplicationRoleItemCollection(_roleManager.Roles.ToList());
        }
        /// <summary>
        /// 设置用于前端页面需要的下拉数据选项
        /// </summary>
        public void SetTypeItems(EmployeeVM boVM)
        {
            boVM.ParentDepartmentItemCollection = SelfReferentialItemFactory <Department> .GetCollection(_departmentRepository, true);

            boVM.JobTitleItemCollection = PlainFacadeItemFactory <JobTitle> .Get(_jobTitleRepository);
        }
 /// <summary>
 /// 设置用于前端页面需要的下拉数据选项
 /// </summary>
 public void SetTypeItems(StudentVM boVM)
 {
     boVM.GradeAndClassItemCollection = SelfReferentialItemFactory <GradeAndClass> .GetCollection(_gradeRepository, true);
 }