using System.Threading.Tasks; using GxPress.EnumConst; using GxPress.Request._AdminVerify; using System.Transactions; namespace GxPress.Service.Implement.AdminVerify { public partial class AdminVerifyService { /// /// 添加好友 /// /// /// public async Task AddFriendAsync(AdminVerifyInFriendsRequest request) { try { using (var transactions = new TransactionScope()) { //判断是否是好友 if (await friendsRepository.ExistsAsync(request.FriendsUserId, request.UserId)) return false; //获取用户信息 var user = await _userRepository.GetAsync(request.UserId); var entity = new Entity.AdminVerify() { VerifyType = GroupTypeConst.Friends, DisposeType = 0, AdminId = request.FriendsUserId, UserId = request.UserId, SourceId = 0, Name = user.Name, AvatarUrl = user.AvatarUrl, Remark = request.Remark, SourceType = 0, AddressBookGroupId = request.AddressBookGroupId }; await _adminVerifyRepository.InsertAsync(entity); transactions.Complete(); } } catch { return false; } return true; } } }