Skip to content

Commit

Permalink
Merge pull request #4679 from aspnetboilerplate/maliming/issue4677
Browse files Browse the repository at this point in the history
fix #4677 AddUserNotificationCountAsync method to add filter parameters.
  • Loading branch information
ismcagdas committed Jul 14, 2019
2 parents 4c2cfb0 + 9a3b8be commit 0f76c7f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/Abp.Zero.Common/Notifications/NotificationStore.cs
Expand Up @@ -269,11 +269,12 @@ public virtual Task<List<UserNotificationInfoWithNotificationInfo>> GetUserNotif
}

[UnitOfWork]
public virtual async Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null)
public virtual async Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null, DateTime? startDate = null, DateTime? endDate = null)
{
using (_unitOfWorkManager.Current.SetTenantId(user.TenantId))
{
return await _userNotificationRepository.CountAsync(un => un.UserId == user.UserId && (state == null || un.State == state.Value));
var predicate = CreateNotificationFilterPredicate(user, state, startDate, endDate);
return await _userNotificationRepository.CountAsync(predicate);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Abp/Notifications/INotificationStore.cs
Expand Up @@ -78,9 +78,9 @@ public interface INotificationStore
/// Gets notifications of a user.
/// </summary>
/// <param name="user">User.</param>
/// <param name="state">State</param>
/// <param name="skipCount">Skip count.</param>
/// <param name="maxResultCount">Maximum result count.</param>
/// <param name="state">State</param>
/// <param name="startDate">List notifications published after startDateTime</param>
/// <param name="endDate">List notifications published before startDateTime</param>
Task<List<UserNotificationInfoWithNotificationInfo>> GetUserNotificationsWithNotificationsAsync(UserIdentifier user, UserNotificationState? state = null, int skipCount = 0, int maxResultCount = int.MaxValue, DateTime? startDate = null, DateTime? endDate = null);
Expand All @@ -90,7 +90,9 @@ public interface INotificationStore
/// </summary>
/// <param name="user">User.</param>
/// <param name="state">The state.</param>
Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null);
/// <param name="startDate">List notifications published after startDateTime</param>
/// <param name="endDate">List notifications published before startDateTime</param>
Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null, DateTime? startDate = null, DateTime? endDate = null);

/// <summary>
/// Gets a user notification.
Expand Down
4 changes: 3 additions & 1 deletion src/Abp/Notifications/IUserNotificationManager.cs
Expand Up @@ -25,7 +25,9 @@ public interface IUserNotificationManager
/// </summary>
/// <param name="user">User.</param>
/// <param name="state">State.</param>
Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null);
/// <param name="startDate">List notifications published after startDateTime</param>
/// <param name="endDate">List notifications published before startDateTime</param>
Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null, DateTime? startDate = null, DateTime? endDate = null);

/// <summary>
/// Gets a user notification by given id.
Expand Down
2 changes: 1 addition & 1 deletion src/Abp/Notifications/NullNotificationStore.cs
Expand Up @@ -81,7 +81,7 @@ public Task<List<UserNotificationInfoWithNotificationInfo>> GetUserNotifications
return Task.FromResult(new List<UserNotificationInfoWithNotificationInfo>());
}

public Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null)
public Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null, DateTime? startDate = null, DateTime? endDate = null)
{
return Task.FromResult(0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Abp/Notifications/UserNotificationManager.cs
Expand Up @@ -29,9 +29,9 @@ public async Task<List<UserNotification>> GetUserNotificationsAsync(UserIdentifi
.ToList();
}

public Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null)
public Task<int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState? state = null, DateTime? startDate = null, DateTime? endDate = null)
{
return _store.GetUserNotificationCountAsync(user, state);
return _store.GetUserNotificationCountAsync(user, state, startDate, endDate);
}

public async Task<UserNotification> GetUserNotificationAsync(int? tenantId, Guid userNotificationId)
Expand Down

0 comments on commit 0f76c7f

Please sign in to comment.