Example #1
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="sysUser"></param>
        /// <returns></returns>
        public async Task <bool> AddUser(SysUser sysUser)
        {
            sysUser.Id = Guid.NewGuid();
            var str      = sysUser.RoleIds;
            var RoleIds  = JsonConvert.DeserializeObject <List <Guid> >(sysUser.RoleIds);
            var Rolelist = new List <SysUserRole>();

            Rolelist.AddRange(RoleIds.Select(x => new SysUserRole
            {
                RoleId        = x,
                CreatedId     = sysUser.CreatedId,
                CreatedName   = sysUser.CreatedName,
                UserIdOrDepId = sysUser.Id,
            }));
            try
            {
                _unitofWork.BeginTransaction();
                await _userRepositoty.InsertAsync(sysUser);

                await _userRoleRepository.InsertAsync(Rolelist);

                _unitofWork.Commit();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="sysUser"></param>
        /// <returns></returns>
        public async Task <bool> AddUser(SysUser sysUser)
        {
            try
            {
                await _userRepositoty.InsertAsync(sysUser);

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }