Beispiel #1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <StatusResult> AddAsync(RoleInputDto input)
        {
            var entity = input.Adapt <Role>();

            entity.Id = Snowflake.GenId();
            var result = await _roleRepository.InsertAsync(entity);

            return(new StatusResult(result == null, "添加失败"));
        }
Beispiel #2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <StatusResult> AddAsync(RoleInputDto input)
        {
            if (_roleRepository.Select.Any(o => o.Name == input.Name))
            {
                return(new StatusResult("角色名已存在"));
            }
            var entity = input.Adapt <RoleEntity>();

            entity.Id = Snowflake.GenId();
            var result = await _roleRepository.InsertAsync(entity);

            return(new StatusResult(result == null, "添加失败"));
        }