27 lines
795 B
C#
27 lines
795 B
C#
using IdentityService.Domain.Entities;
|
|
using IM.Commons;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace IdentityService.Domain
|
|
{
|
|
public class IdDomainService
|
|
{
|
|
private readonly IIdRepository idRepository;
|
|
public IdDomainService(IIdRepository idRepository)
|
|
{
|
|
this.idRepository = idRepository;
|
|
}
|
|
|
|
public async Task<Result<User?>> CreateUserAsync(string userName, string password, string nickName)
|
|
{
|
|
SignInResult checkUsername = await idRepository.CheckUsernameAsync(userName);
|
|
if (!checkUsername.Succeeded)
|
|
{
|
|
return Result<User?>.Fail(ResultCode.USER_ALREADY_EXISTS);
|
|
}
|
|
return Result<User?>.Success(new User(userName, nickName));
|
|
}
|
|
|
|
}
|
|
}
|