ShortMessagesApplicationService.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Threading.Tasks;
  3. using Abp.Authorization;
  4. using Abp.Domain.Repositories;
  5. using IwbZero.AppServiceBase;
  6. using ShwasherSys.NotificationInfo.Dto;
  7. namespace ShwasherSys.NotificationInfo
  8. {
  9. [AbpAuthorize]
  10. public class ShortMessagesAppService : ShwasherAsyncCrudAppService<ShortMessage, ShortMessageDto, int, PagedRequestDto, ShortMessageCreateDto, ShortMessageUpdateDto >, IShortMessagesAppService
  11. {
  12. protected IRepository<ShortMsgDetail> ShortMsgDetailRepository;
  13. public ShortMessagesAppService(IRepository<ShortMessage, int> repository, IRepository<ShortMsgDetail> shortMsgDetailRepository) : base(repository)
  14. {
  15. ShortMsgDetailRepository = shortMsgDetailRepository;
  16. }
  17. protected override string GetPermissionName { get; set; } //= PermissionNames.PagesShortMessage;
  18. protected override string GetAllPermissionName { get; set; } //= PermissionNames.PagesShortMessage;
  19. protected override string CreatePermissionName { get; set; } //= PermissionNames.PagesShortMessageCreate;
  20. protected override string UpdatePermissionName { get; set; } //= PermissionNames.PagesShortMessageUpdate;
  21. protected override string DeletePermissionName { get; set; } //= PermissionNames.PagesShortMessageDelete;
  22. public override async Task<ShortMessageDto> Create(ShortMessageCreateDto input)
  23. {
  24. CheckCreatePermission();
  25. var resultEntity = await CreateEntity(input);
  26. string lcReciveUsers = resultEntity.RecieveUserIds ?? throw new ArgumentNullException("resultEntity.RecieveUserIds");
  27. string[] userNames = lcReciveUsers.Split(',');
  28. foreach (var userName in userNames)
  29. {
  30. ShortMsgDetail loDetail = new ShortMsgDetail()
  31. {
  32. IsRead = "N",
  33. MsgID = resultEntity.Id,
  34. RecvUserID = userName
  35. };
  36. ShortMsgDetailRepository.Insert(loDetail);
  37. }
  38. return resultEntity;
  39. }
  40. }
  41. }