diff --git a/Back/Back.csproj b/Back/Back.csproj
index 899d7e4..fd97cd7 100644
--- a/Back/Back.csproj
+++ b/Back/Back.csproj
@@ -36,7 +36,7 @@
- ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll
+ ..\..\Dlls\Service.dll
diff --git a/Back/Controllers/UserController.cs b/Back/Controllers/UserController.cs
index 75069a9..0128a63 100644
--- a/Back/Controllers/UserController.cs
+++ b/Back/Controllers/UserController.cs
@@ -18,8 +18,9 @@ namespace Back.Controllers
private readonly MobileValidation _mobilevalidation;
private readonly ServValidatinMsg _servValidatinMsg;
private readonly servSendMsg _servSendMsg;
+ private readonly servNotification _servNotification;
public UserController(servUser servUser, MobileValidation mobilevalidation, servCompany servCompany
- , ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg)
+ , ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg, servNotification servNotification)
{
_servUser = servUser;
@@ -27,6 +28,7 @@ namespace Back.Controllers
_servCompany = servCompany;
_servValidatinMsg = servValidatinMsg;
_servSendMsg = servSendMsg;
+ _servNotification = servNotification;
}
[HttpPost("authenticate")]
[AllowAnonymous]
@@ -92,6 +94,15 @@ namespace Back.Controllers
return Ok(await _servUser.GetDashBoard(Convert.ToInt32(UserID)));
}
+ [HttpPut("ReadNotification/{ntID}")]
+ public async Task> ReadNotification(int ntID)
+ {
+ var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
+ var UserID = claim.Value;
+ return Ok(await _servNotification.ReadNotification(Convert.ToInt32(UserID), ntID));
+
+
+ }
}
}
diff --git a/Back/Data/Infrastructure/Persistence/SqlDbContext.cs b/Back/Data/Infrastructure/Persistence/SqlDbContext.cs
index ad81e8b..ffb2146 100644
--- a/Back/Data/Infrastructure/Persistence/SqlDbContext.cs
+++ b/Back/Data/Infrastructure/Persistence/SqlDbContext.cs
@@ -43,6 +43,7 @@ namespace TaxPayer.Infrastructure.Persistence
public DbSet OrderDiscountCodes { get; set; }
public DbSet TiceketUnknownPeoples { get; set; }
public DbSet SaleLeads { get; set; }
+ public DbSet UserNotifis { get; set; }
#endregion
//public override Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
//{
diff --git a/Back/Data/Models/Notification.cs b/Back/Data/Models/Notification.cs
index 07cffc5..a0f54f0 100644
--- a/Back/Data/Models/Notification.cs
+++ b/Back/Data/Models/Notification.cs
@@ -5,9 +5,10 @@
public int ID { get; set; }
public int Type { get; set; }
public string Message { get; set; }
- public string? Path { get; set; }
- public string? ViewSize { get; set; }
+ public string Title { get; set; }
public string Date { get; set; }
- public bool Status { get; set; }
+ public int Status { get; set; }
+ public string? ForUser { get; set; }
+
}
}
diff --git a/Back/Data/Models/UserNotfi.cs b/Back/Data/Models/UserNotfi.cs
new file mode 100644
index 0000000..fb7aa1e
--- /dev/null
+++ b/Back/Data/Models/UserNotfi.cs
@@ -0,0 +1,9 @@
+namespace Back.Data.Models
+{
+ public class UserNotfi
+ {
+ public int ID { get; set; }
+ public int UserID { get; set; }
+ public int NotificationID { get; set; }
+ }
+}
diff --git a/Back/Services/servNotification.cs b/Back/Services/servNotification.cs
index 901adbd..cb9b490 100644
--- a/Back/Services/servNotification.cs
+++ b/Back/Services/servNotification.cs
@@ -7,14 +7,27 @@ namespace Back.Services
public class servNotification
{
private readonly IAsyncRepository _NotificationRepo;
-
- public servNotification(IAsyncRepository NotificationRepo)
+ private readonly IAsyncRepository _UserNotfiRepo;
+ public servNotification(IAsyncRepository NotificationRepo, IAsyncRepository userNotfiRepo)
{
_NotificationRepo = NotificationRepo;
+ _UserNotfiRepo = userNotfiRepo;
}
- public async Task> GetNotifications()
+ public async Task ReadNotification(int UserID,int ntID)
{
- return await _NotificationRepo.Get(w=>w.Status).ToListAsync();
+ if (!await _UserNotfiRepo.Get(w => w.UserID == UserID && w.NotificationID == ntID).AnyAsync())
+ return await _UserNotfiRepo.AddBoolResultAsync(new UserNotfi
+ {
+ NotificationID = ntID,
+ UserID = UserID,
+ });
+ else return true;
+ }
+ public async Task> GetNotifications(int UserID)
+ {
+ var readmsg=await _UserNotfiRepo.Get(w => w.UserID == UserID).Select(s=>s.NotificationID).ToListAsync();
+
+ return await _NotificationRepo.Get(w=>(string.IsNullOrEmpty(w.ForUser) || w.ForUser.Contains("/"+UserID.ToString()+"/"))&& !readmsg.Contains(w.ID)).ToListAsync();
}
}
}
diff --git a/Back/Services/servUser.cs b/Back/Services/servUser.cs
index c841d45..66e449d 100644
--- a/Back/Services/servUser.cs
+++ b/Back/Services/servUser.cs
@@ -244,14 +244,14 @@ namespace Back.Services
request.Warning.Add(new AlertDTO { Status = 5, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
}
}
- var nots = await _servNotification.GetNotifications();
+ var nots = await _servNotification.GetNotifications(UserID);
if (nots.Any())
request.Notifications = nots.Select(s => new AlertDTO
{
+ ViewSize=s.ID.ToString(),
Message = s.Message,
Status = s.Type,
- Path = s.Path,
- ViewSize = s.ViewSize
+ Path = s.Title
}).ToList();
LastActivitySevice lastInvoice = new LastActivitySevice();
diff --git a/TaxPayerFull/CUSComponent/Notifications.razor b/TaxPayerFull/CUSComponent/Notifications.razor
index e522866..97c1414 100644
--- a/TaxPayerFull/CUSComponent/Notifications.razor
+++ b/TaxPayerFull/CUSComponent/Notifications.razor
@@ -1,11 +1,25 @@
-@using Shared.DTOs
-Notifications
-@items.Count()
+@using Front.Services
+@using Shared.DTOs
+@inject HttpClientController hc;
+@inject Fixedvalues fv;
+@foreach (var item in items)
+{
+ @item.Message
+}
- Holy guacamole! You should check in on some of those fields below.
@code {
[Parameter] public List items { get; set; }
+ public async Task OnClosedAlert(AlertDTO nt)
+ {
+ var rsp= await hc.Put($"User/ReadNotification/{Convert.ToInt32(nt.ViewSize)}");
+ // if (rsp.IsSuccessStatusCode)
+ // {
+ // fv.dashBoard.Notifications.Remove(nt);
+
+ // }
+
+ }
}
diff --git a/TaxPayerFull/Layout/PanelLayout.razor b/TaxPayerFull/Layout/PanelLayout.razor
index ea76c7d..d673caf 100644
--- a/TaxPayerFull/Layout/PanelLayout.razor
+++ b/TaxPayerFull/Layout/PanelLayout.razor
@@ -166,11 +166,15 @@
-
-
-
+ @if (dashBoard?.Notifications.Count()>0)
+ {
+
+
+
+ }
+
diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs
index f8805c2..628e6c3 100644
--- a/TaxPayerFull/Program.cs
+++ b/TaxPayerFull/Program.cs
@@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
}) ;
-//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
+builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
-builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
+//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");