using ContactService.Domain.Entities; using ContactService.Domain.ValueObjects; using IM.Commons; namespace ContactService.Domain { public class FriendDomainService { private readonly IFriendReposity reposity; public FriendDomainService(IFriendReposity reposity) { this.reposity = reposity; } public async Task> CreateAsync(UserProfile owner, UserProfile target, string? remarkName) { var isExist = await reposity.CheckOwnerIdAndTargetIdAsync(owner.Id, target.Id); if (isExist) { return Result.Fail(ResultCode.ALREADY_FRIENDS); } var friend = new Friend(owner, target, remarkName); var res = await reposity.CreateAsync(friend); return Result.Success(res); } } }