TopicService.Delete.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Threading.Tasks;
  3. using System.Transactions;
  4. using Datory;
  5. using GxPress.Entity.Topic;
  6. namespace GxPress.Service.Implement.Topic
  7. {
  8. public partial class TopicService
  9. {
  10. /// <summary>
  11. /// 删除话题
  12. /// </summary>
  13. /// <param name="id"></param>
  14. /// <returns></returns>
  15. public async Task<bool> DeleteAsync(int id)
  16. {
  17. try
  18. {
  19. using (TransactionScope transactionScope = new TransactionScope())
  20. {
  21. //删除话题
  22. await _topicRepository.DeleteAsync(id);
  23. //删除话题用户
  24. //await _topicAddresseeRepository.DeleteAsync(Q.Where(nameof(TopicAddressee.TopicId), id));
  25. transactionScope.Complete();
  26. }
  27. }
  28. catch (Exception e)
  29. {
  30. Console.WriteLine(e);
  31. throw;
  32. }
  33. return true;
  34. }
  35. }
  36. }