Gestita pagina notifiche
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using System.Text.Json.Serialization;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
@@ -10,6 +11,11 @@ public class ActivityDTO : StbActivity
|
||||
public ActivityCategoryEnum Category { get; set; }
|
||||
public bool Complete { get; set; }
|
||||
|
||||
//Notification
|
||||
public int MinuteBefore { get; set; } = -1;
|
||||
[JsonPropertyName("notificationDate")]
|
||||
public DateTime? NotificationDate { get; set; }
|
||||
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
public PositionDTO? Position { get; set; }
|
||||
@@ -23,6 +29,9 @@ public class ActivityDTO : StbActivity
|
||||
{
|
||||
return Commessa == other.Commessa &&
|
||||
Cliente == other.Cliente &&
|
||||
Position == other.Position &&
|
||||
MinuteBefore == other.MinuteBefore &&
|
||||
NotificationDate == other.NotificationDate &&
|
||||
Category == other.Category &&
|
||||
Complete == other.Complete && ActivityId == other.ActivityId && ActivityResultId == other.ActivityResultId && ActivityTypeId == other.ActivityTypeId && DataInsAct.Equals(other.DataInsAct) && ActivityDescription == other.ActivityDescription && ParentActivityId == other.ParentActivityId && TipoAnag == other.TipoAnag && CodAnag == other.CodAnag && CodJcom == other.CodJcom && CodJfas == other.CodJfas && Nullable.Equals(EstimatedDate, other.EstimatedDate) && Nullable.Equals(EstimatedTime, other.EstimatedTime) && Nullable.Equals(AlarmDate, other.AlarmDate) && Nullable.Equals(AlarmTime, other.AlarmTime) && Nullable.Equals(EffectiveDate, other.EffectiveDate) && Nullable.Equals(EffectiveTime, other.EffectiveTime) && ResultDescription == other.ResultDescription && Nullable.Equals(EstimatedEnddate, other.EstimatedEnddate) && Nullable.Equals(EstimatedEndtime, other.EstimatedEndtime) && Nullable.Equals(EffectiveEnddate, other.EffectiveEnddate) && Nullable.Equals(EffectiveEndtime, other.EffectiveEndtime) && UserCreator == other.UserCreator && UserName == other.UserName && Nullable.Equals(PercComp, other.PercComp) && Nullable.Equals(EstimatedHours, other.EstimatedHours) && CodMart == other.CodMart && PartitaMag == other.PartitaMag && Matricola == other.Matricola && Priorita == other.Priorita && Nullable.Equals(ActivityPlayCounter, other.ActivityPlayCounter) && ActivityEvent == other.ActivityEvent && Guarantee == other.Guarantee && Note == other.Note && Rfid == other.Rfid && IdLotto == other.IdLotto && PersonaRif == other.PersonaRif && HrNum == other.HrNum && Gestione == other.Gestione && Nullable.Equals(DataOrd, other.DataOrd) && NumOrd == other.NumOrd && IdStep == other.IdStep && IdRiga == other.IdRiga && Nullable.Equals(OraInsAct, other.OraInsAct) && IndiceGradimento == other.IndiceGradimento && NoteGradimento == other.NoteGradimento && FlagRisolto == other.FlagRisolto && FlagTipologia == other.FlagTipologia && OreRapportino == other.OreRapportino && UserModifier == other.UserModifier && Nullable.Equals(OraModAct, other.OraModAct) && Nullable.Equals(OraViewAct, other.OraViewAct) && CodVdes == other.CodVdes && CodCmac == other.CodCmac && WrikeId == other.WrikeId && CodMgrp == other.CodMgrp && PlanId == other.PlanId;
|
||||
}
|
||||
@@ -97,6 +106,9 @@ public class ActivityDTO : StbActivity
|
||||
hashCode.Add(Cliente);
|
||||
hashCode.Add(Category);
|
||||
hashCode.Add(Complete);
|
||||
hashCode.Add(Position);
|
||||
hashCode.Add(MinuteBefore);
|
||||
hashCode.Add(NotificationDate);
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace salesbook.Shared.Core.Dto.Notification;
|
||||
|
||||
public class PushNotificationDTO
|
||||
{
|
||||
public string? Title { get; set; }
|
||||
public string? Message { get; set; }
|
||||
|
||||
public DateTime Hours => DateTime.Now;
|
||||
}
|
||||
12
salesbook.Shared/Core/Dto/NotificationDataDTO.cs
Normal file
12
salesbook.Shared/Core/Dto/NotificationDataDTO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class NotificationDataDTO
|
||||
{
|
||||
[JsonPropertyName("activityId")]
|
||||
public string? ActivityId { get; set; }
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public string? Type { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
public class NotificationState
|
||||
{
|
||||
public List<PushNotificationDTO> UnreadNotifications { get; set; } = [];
|
||||
public List<WtbNotification> ReceivedNotifications { get; set; } = [];
|
||||
public List<WtbNotification> UnreadNotifications { get; set; } = [];
|
||||
public List<WtbNotification> NotificationsRead { get; set; } = [];
|
||||
|
||||
public int Count => ReceivedNotifications.Count() + UnreadNotifications.Count();
|
||||
}
|
||||
15
salesbook.Shared/Core/Dto/ReadNotificationRequestDTO.cs
Normal file
15
salesbook.Shared/Core/Dto/ReadNotificationRequestDTO.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class ReadNotificationRequestDTO
|
||||
{
|
||||
[JsonPropertyName("deviceToken")]
|
||||
public string DeviceToken { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationId")]
|
||||
public long NotificationId { get; set; }
|
||||
}
|
||||
15
salesbook.Shared/Core/Entity/WtbDeviceNotification.cs
Normal file
15
salesbook.Shared/Core/Entity/WtbDeviceNotification.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
public class WtbDeviceNotification
|
||||
{
|
||||
[JsonPropertyName("userDeviceId")]
|
||||
public long? UserDeviceId { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationId")]
|
||||
public long? NotificationId { get; set; }
|
||||
|
||||
[JsonPropertyName("readDate")]
|
||||
public DateTime? ReadDate { get; set; }
|
||||
}
|
||||
37
salesbook.Shared/Core/Entity/WtbNotification.cs
Normal file
37
salesbook.Shared/Core/Entity/WtbNotification.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
public class WtbNotification
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonPropertyName("body")]
|
||||
public string? Body { get; set; }
|
||||
|
||||
[JsonPropertyName("imageUrl")]
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationData")]
|
||||
public NotificationDataDTO? NotificationData { get; set; }
|
||||
|
||||
[JsonPropertyName("startDate")]
|
||||
public DateTime? StartDate { get; set; }
|
||||
|
||||
[JsonPropertyName("endDate")]
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
[JsonPropertyName("persistent")]
|
||||
public bool? Persistent { get; set; }
|
||||
|
||||
[JsonPropertyName("topics")]
|
||||
public List<string>? Topics { get; set; }
|
||||
|
||||
[JsonPropertyName("wtbDeviceNotifications")]
|
||||
public List<WtbDeviceNotification>? WtbDeviceNotifications { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
public interface IIntegryNotificationRestClient
|
||||
{
|
||||
Task Register(string fcmToken, ILogger? logger1 = null);
|
||||
Task<List<WtbNotification>> Get();
|
||||
Task<WtbNotification> MarkAsRead(long id);
|
||||
Task Delete(long id);
|
||||
Task DeleteAll();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
public interface IIntegryRegisterNotificationRestClient
|
||||
{
|
||||
Task Register(string fcmToken, ILogger? logger1 = null);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
|
||||
public class NewPushNotificationMessage(PushNotificationDTO value) : ValueChangedMessage<PushNotificationDTO>(value);
|
||||
public class NewPushNotificationMessage(WtbNotification value) : ValueChangedMessage<WtbNotification>(value);
|
||||
@@ -1,11 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
|
||||
public class NewPushNotificationService
|
||||
{
|
||||
public event Action<PushNotificationDTO>? OnNotificationReceived;
|
||||
public event Action<WtbNotification>? OnNotificationReceived;
|
||||
|
||||
public NewPushNotificationService(IMessenger messenger)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
namespace salesbook.Shared.Core.Services;
|
||||
|
||||
public class IntegryNotificationRestClient(
|
||||
IUserSession userSession,
|
||||
IIntegryApiRestClient integryApiRestClient) : IIntegryNotificationRestClient
|
||||
{
|
||||
public Task<List<WtbNotification>> Get()
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>
|
||||
{
|
||||
{ "mode", "ENABLED" },
|
||||
{ "forUser", userSession.User.Username }
|
||||
};
|
||||
|
||||
return integryApiRestClient.Get<List<WtbNotification>>("notification", queryParams)!;
|
||||
}
|
||||
|
||||
public Task<WtbNotification> MarkAsRead(long id) =>
|
||||
integryApiRestClient.Post<WtbNotification>("notification/read",
|
||||
new ReadNotificationRequestDTO { NotificationId = id, Username = userSession.User.Username })!;
|
||||
|
||||
public Task Delete(long id) =>
|
||||
integryApiRestClient.Delete<object>($"notification/{id}", null);
|
||||
|
||||
public Task DeleteAll() =>
|
||||
integryApiRestClient.Delete<object>($"notification/all/{userSession.User.Username}", null);
|
||||
}
|
||||
Reference in New Issue
Block a user