| | | 1 | | using KT.Modules.Security.Presentation.Contracts; |
| | | 2 | | using KT.Modules.Security.Presentation.Dto; |
| | | 3 | | using Microsoft.Extensions.DependencyInjection; |
| | | 4 | | |
| | | 5 | | namespace KT.Modules.Alarm.Core.Application |
| | | 6 | | { |
| | 10 | 7 | | internal class DeviceTokenService([FromKeyedServices("securityModule")] IDeviceTokenService deviceTokenService) : ID |
| | | 8 | | { |
| | | 9 | | public Task<bool> DeleteAsync(string token) |
| | 3 | 10 | | { |
| | 3 | 11 | | if (string.IsNullOrEmpty(token)) |
| | 2 | 12 | | return Task.FromResult(false); |
| | 1 | 13 | | return deviceTokenService.DeleteAsync(token); |
| | 3 | 14 | | } |
| | | 15 | | public async Task<string> GetAsync(string userId) |
| | 2 | 16 | | { |
| | 2 | 17 | | if (string.IsNullOrEmpty(userId)) |
| | 1 | 18 | | throw new ArgumentException("UserId cannot be null or empty"); |
| | 1 | 19 | | return await deviceTokenService.GetAsync(userId); |
| | 1 | 20 | | } |
| | | 21 | | public async Task SaveAsync(DeviceTokenDto deviceToken) |
| | 5 | 22 | | { |
| | 5 | 23 | | if (deviceToken == null || string.IsNullOrEmpty(deviceToken.UserId) || string.IsNullOrEmpty(deviceToken.Toke |
| | 4 | 24 | | throw new ArgumentException("DeviceToken, Username, and Token cannot be null or empty"); |
| | 1 | 25 | | await deviceTokenService.SaveAsync(deviceToken); |
| | 1 | 26 | | } |
| | | 27 | | } |
| | | 28 | | } |