Esempio n. 1
0
 /// <summary>
 /// 视图对象的属性转换为业务对象的属性
 /// </summary>
 /// <param name="bo"></param>
 private void _VMMapToBo(ApplicationRole bo, ApplicationRoleVM boVM)
 {
     bo.Id                  = boVM.Id;
     bo.Name                = boVM.Name;
     bo.Description         = boVM.Description;
     bo.SortCode            = boVM.SortCode;
     bo.ApplicationRoleType = boVM.ApplicationRoleType;
 }
Esempio n. 2
0
 /// <summary>
 /// 业务对象的属性转换为视图对象的属性
 /// </summary>
 /// <param name="bo"></param>
 private void _BoMapToVM(ApplicationRole bo, ApplicationRoleVM boVM)
 {
     boVM.Id                                = bo.Id;
     boVM.Name                              = bo.Name;
     boVM.Description                       = bo.Description;
     boVM.SortCode                          = bo.SortCode;
     boVM.ApplicationRoleType               = bo.ApplicationRoleType;
     boVM.ApplicationRoleTypeName           = bo.ApplicationRoleType.ToString();
     boVM.ApplicationRoleTypeItemCollection = _GetByEnum(bo.ApplicationRoleType);
 }
Esempio n. 3
0
        /// <summary>
        /// 根据角色组对象 Id 返回一个角色组实体视图模型,如果传入的 Id 找不到对应的角色对象,则返回一个新的视图模型对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ApplicationRoleVM> GetVM(Guid id)
        {
            var boVM = new ApplicationRoleVM();
            var bo   = await _roleManager.FindByIdAsync(id.ToString());

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

            _BoMapToVM(bo, boVM);

            return(boVM);
        }
Esempio n. 4
0
        /// <summary>
        /// 保存角色组数据
        /// </summary>
        /// <param name="boVM"></param>
        /// <returns></returns>
        public async Task <bool> SaveBo(ApplicationRoleVM boVM)
        {
            var bo = await _roleManager.FindByIdAsync(boVM.Id.ToString());

            if (bo != null)
            {
                _VMMapToBo(bo, boVM);
                var result = await _roleManager.UpdateAsync(bo);

                boVM.ApplicationRoleTypeItemCollection = _GetByEnum(boVM.ApplicationRoleType);

                if (result.Succeeded)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                bo = new ApplicationRole();
                _VMMapToBo(bo, boVM);
                var result = await _roleManager.CreateAsync(bo);

                boVM.ApplicationRoleTypeItemCollection = _GetByEnum(boVM.ApplicationRoleType);

                if (result.Succeeded)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 设置角色组与关联多项相关的视图模型属性
 /// </summary>
 /// <param name="boVM"></param>
 public void SetTypeItems(ApplicationRoleVM boVM)
 {
     boVM.ApplicationRoleTypeItemCollection = _GetByEnum(boVM.ApplicationRoleType);
 }