Exemple #1
0
        public async Task <string> Create(CreateUserInput input)
        {
            input.CheckDataAnnotations().CheckValidResult();
            var existUser = await _userRepository.FirstOrDefaultAsync(p => p.UserName == input.UserName);

            if (existUser != null)
            {
                throw new UserFriendlyException($"已经存在用户名为{input.UserName}的用户");
            }
            existUser = await _userRepository.FirstOrDefaultAsync(p => p.Phone == input.Phone);

            if (existUser != null)
            {
                throw new UserFriendlyException($"已经存在手机号码为{input.Phone}的用户");
            }
            existUser = await _userRepository.FirstOrDefaultAsync(p => p.Email == input.Email);

            if (existUser != null)
            {
                throw new UserFriendlyException($"已经存在Email为{input.Email}的用户");
            }

            await _userDomainService.Create(input);

            return("新增员工成功");
        }
Exemple #2
0
        public async Task <string> Create(CreateUserInput input)
        {
            input.CheckDataAnnotations().CheckValidResult();
            var exsitUserInfo = await _userRepository.FirstOrDefaultAsync(p => p.UserName == input.UserName ||
                                                                          p.Email == input.Email ||
                                                                          p.Phone == input.Phone);

            if (exsitUserInfo != null)
            {
                throw new BusinessException("已经存在该员工信息,请检查员工账号信息");
            }

            var userInfo = input.MapTo <UserInfo>();
            await _userManager.CreateUserInfo(userInfo);

            return("新增员工成功");
        }