Ejemplo n.º 1
0
        /// <summary>
        ///     新增角色
        /// </summary>
        /// <param name="info">角色实体</param>
        /// <returns></returns>
        public async Task CreateRoleAsync(Role info)
        {
            //保存角色
            var key = await _roleRepository.InsertAndGetIdAsync(info);

            //设置编码
            info.Code         = info.Name.ChineseConverterToSpell() + "#" + key;
            info.BelongUserId = AprilSession.BelongUserId;
            //更新角色
            await UpdateRoleAsync(info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="list"></param>
        /// <param name="menuId"></param>
        /// <returns></returns>
        public async Task BatchInsertMenuAppAuthorizeAsync(List <MenuAppAuthorize> list, long menuId)
        {
            var keyArray = new List <long>();

            using (var unitOfWork = _unitOfWorkManager.Begin()) //启用工作单元
            {
                var first = list.FirstOrDefault();
                foreach (var item in list)
                {
                    Expression <Func <MenuAppAuthorize, bool> > where =
                        w => w.MenuId == item.MenuId &&
                        w.MenuCode == item.MenuCode &&
                        w.AppCode == item.AppCode &&
                        w.OperationCode == item.OperationCode;

                    var predicate = new PredicateGroup <MenuAppAuthorize>();
                    predicate.AddPredicate(true, where);

                    var entity = await _repository.QueryEntityAsync(predicate.Predicates);

                    if (entity != null)
                    {
                        keyArray.Add(entity.Id);
                    }
                    else
                    {
                        var key = await _repository.InsertAndGetIdAsync(item);

                        keyArray.Add(key);
                    }
                }
                if (first != null)
                {
                    await _repository.DeleteAsync(x => !(keyArray.Contains(x.Id)) &&
                                                  x.MenuId == first.MenuId);
                }
                else
                {
                    await _repository.DeleteAsync(x => x.MenuId == menuId);
                }

                await unitOfWork.CompleteAsync();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     新增用户返回Id
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public async Task <long> CreateUserAndGetIdAsync(UserBase user)
 {
     return(await _userBaseRepository.InsertAndGetIdAsync(user));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity">菜单实体</param>
        /// <returns></returns>
        public async Task <long> InsertAsync(Menu entity)
        {
            var entityId = await _menuRepository.InsertAndGetIdAsync(entity);

            return(entityId);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     新增后台用户返回Id
 /// </summary>
 /// <param name="manager"></param>
 /// <returns></returns>
 public async Task <long> InsertManagerAndGetIdAsync(Manager manager)
 {
     return(await _managerRepository.InsertAndGetIdAsync(manager));
 }