/
UserNotificationManager.cs
68 lines (58 loc) · 2.47 KB
/
UserNotificationManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.Dependency;
namespace Abp.Notifications
{
/// <summary>
/// Implements <see cref="IUserNotificationManager"/>.
/// </summary>
public class UserNotificationManager : IUserNotificationManager, ISingletonDependency
{
private readonly INotificationStore _store;
/// <summary>
/// Initializes a new instance of the <see cref="UserNotificationManager"/> class.
/// </summary>
public UserNotificationManager(INotificationStore store)
{
_store = store;
}
public async Task<List<UserNotification>> GetUserNotificationsAsync(UserIdentifier user, UserNotificationState? state = null, int skipCount = 0, int maxResultCount = int.MaxValue)
{
var userNotifications = await _store.GetUserNotificationsWithNotificationsAsync(user, state, skipCount, maxResultCount);
return userNotifications
.Select(un => un.ToUserNotification())
.ToList();
}
public Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null)
{
return _store.GetUserNotificationCountAsync(user, state);
}
public async Task<UserNotification> GetUserNotificationAsync(int? tenantId, Guid userNotificationId)
{
var userNotification = await _store.GetUserNotificationWithNotificationOrNullAsync(tenantId, userNotificationId);
if (userNotification == null)
{
return null;
}
return userNotification.ToUserNotification();
}
public Task UpdateUserNotificationStateAsync(int? tenantId, Guid userNotificationId, UserNotificationState state)
{
return _store.UpdateUserNotificationStateAsync(tenantId, userNotificationId, state);
}
public Task UpdateAllUserNotificationStatesAsync(UserIdentifier user, UserNotificationState state)
{
return _store.UpdateAllUserNotificationStatesAsync(user, state);
}
public Task DeleteUserNotificationAsync(int? tenantId, Guid userNotificationId)
{
return _store.DeleteUserNotificationAsync(tenantId, userNotificationId);
}
public Task DeleteAllUserNotificationsAsync(UserIdentifier user)
{
return _store.DeleteAllUserNotificationsAsync(user);
}
}
}