Migliorata gestione e visualizzazione notifiche
This commit is contained in:
@@ -15,6 +15,7 @@ public interface IManageDataService
|
||||
Task<List<ContactDTO>> GetContact(WhereCondContact whereCond);
|
||||
Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact);
|
||||
|
||||
Task<List<ActivityDTO>> GetActivityTryLocalDb(WhereCondActivity whereCond);
|
||||
Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false);
|
||||
|
||||
Task InsertOrUpdate<T>(T objectToSave);
|
||||
|
||||
7
salesbook.Shared/Core/Interface/INotificationService.cs
Normal file
7
salesbook.Shared/Core/Interface/INotificationService.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace salesbook.Shared.Core.Interface;
|
||||
|
||||
public interface INotificationService
|
||||
{
|
||||
Task LoadNotification();
|
||||
void OrderNotificationList();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification.Loaded;
|
||||
|
||||
public class NotificationsLoadedMessage(object? value = null) : ValueChangedMessage<object?>(value);
|
||||
@@ -0,0 +1,13 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification.Loaded;
|
||||
|
||||
public class NotificationsLoadedService
|
||||
{
|
||||
public event Action? OnNotificationsLoaded;
|
||||
|
||||
public NotificationsLoadedService(IMessenger messenger)
|
||||
{
|
||||
messenger.Register<NotificationsLoadedMessage>(this, (_, _) => { OnNotificationsLoaded?.Invoke(); });
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
namespace salesbook.Shared.Core.Messages.Notification.NewPush;
|
||||
|
||||
public class NewPushNotificationMessage(WtbNotification value) : ValueChangedMessage<WtbNotification>(value);
|
||||
@@ -1,7 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
namespace salesbook.Shared.Core.Messages.Notification.NewPush;
|
||||
|
||||
public class NewPushNotificationService
|
||||
{
|
||||
45
salesbook.Shared/Core/Services/NotificationService.cs
Normal file
45
salesbook.Shared/Core/Services/NotificationService.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using salesbook.Shared.Core.Dto.PageState;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
namespace salesbook.Shared.Core.Services;
|
||||
|
||||
public class NotificationService(
|
||||
IIntegryNotificationRestClient integryNotificationRestClient,
|
||||
NotificationState Notification
|
||||
) : INotificationService
|
||||
{
|
||||
public async Task LoadNotification()
|
||||
{
|
||||
var allNotifications = await integryNotificationRestClient.Get();
|
||||
var allIds = allNotifications.Select(n => n.Id).ToHashSet();
|
||||
|
||||
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
||||
.Where(r => !allIds.Contains(r.Id))
|
||||
.ToList();
|
||||
|
||||
Notification.UnreadNotifications = allNotifications
|
||||
.Where(x =>
|
||||
x.WtbDeviceNotifications == null ||
|
||||
x.WtbDeviceNotifications.Any(y => y.ReadDate == null))
|
||||
.ToList();
|
||||
|
||||
Notification.NotificationsRead = allNotifications
|
||||
.Where(x =>
|
||||
x.WtbDeviceNotifications != null &&
|
||||
x.WtbDeviceNotifications.All(y => y.ReadDate != null))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void OrderNotificationList()
|
||||
{
|
||||
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
|
||||
Notification.UnreadNotifications = Notification.UnreadNotifications
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
|
||||
Notification.NotificationsRead = Notification.NotificationsRead
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user