AdminVerifyService.AddFriends.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Threading.Tasks;
  2. using GxPress.EnumConst;
  3. using GxPress.Request._AdminVerify;
  4. using System.Transactions;
  5. namespace GxPress.Service.Implement.AdminVerify
  6. {
  7. public partial class AdminVerifyService
  8. {
  9. /// <summary>
  10. /// 添加好友
  11. /// </summary>
  12. /// <param name="request"></param>
  13. /// <returns></returns>
  14. public async Task<bool> AddFriendAsync(AdminVerifyInFriendsRequest request)
  15. {
  16. try
  17. {
  18. using (var transactions = new TransactionScope())
  19. {
  20. //获取用户信息
  21. var user = await _userRepository.GetAsync(request.FriendsUserId);
  22. var entity = new Entity.AdminVerify()
  23. {
  24. //
  25. VerifyType = GroupTypeConst.Friends,
  26. DisposeType = 0,
  27. AdminId = request.FriendsUserId,
  28. UserId = request.UserId,
  29. SourceId = 0,
  30. Name = user.Name,
  31. AvatarUrl = user.AvatarUrl,
  32. Remark = request.Remark,
  33. SourceType = 0,
  34. AddressBookGroupId = request.AddressBookGroupId
  35. };
  36. await _adminVerifyRepository.InsertAsync(entity);
  37. // //获取用户信息
  38. // user = await _userRepository.GetAsync(request.UserId);
  39. // entity = new Entity.AdminVerify()
  40. // {
  41. // //
  42. // VerifyType = GroupTypeConst.Friends,
  43. // DisposeType = 0,
  44. // AdminId = request.UserId,
  45. // UserId = request.FriendsUserId,
  46. // SourceId = 0,
  47. // Name = user.Name,
  48. // AvatarUrl = user.AvatarUrl,
  49. // Remark = request.Remark,
  50. // SourceType = 0,
  51. // AddressBookGroupId = 0
  52. // };
  53. // await _adminVerifyRepository.InsertAsync(entity);
  54. transactions.Complete();
  55. }
  56. }
  57. catch
  58. {
  59. return false;
  60. }
  61. return true;
  62. }
  63. }
  64. }