read not
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Service">
|
<Reference Include="Service">
|
||||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@@ -18,8 +18,9 @@ namespace Back.Controllers
|
|||||||
private readonly MobileValidation _mobilevalidation;
|
private readonly MobileValidation _mobilevalidation;
|
||||||
private readonly ServValidatinMsg _servValidatinMsg;
|
private readonly ServValidatinMsg _servValidatinMsg;
|
||||||
private readonly servSendMsg _servSendMsg;
|
private readonly servSendMsg _servSendMsg;
|
||||||
|
private readonly servNotification _servNotification;
|
||||||
public UserController(servUser servUser, MobileValidation mobilevalidation, servCompany servCompany
|
public UserController(servUser servUser, MobileValidation mobilevalidation, servCompany servCompany
|
||||||
, ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg)
|
, ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg, servNotification servNotification)
|
||||||
{
|
{
|
||||||
|
|
||||||
_servUser = servUser;
|
_servUser = servUser;
|
||||||
@@ -27,6 +28,7 @@ namespace Back.Controllers
|
|||||||
_servCompany = servCompany;
|
_servCompany = servCompany;
|
||||||
_servValidatinMsg = servValidatinMsg;
|
_servValidatinMsg = servValidatinMsg;
|
||||||
_servSendMsg = servSendMsg;
|
_servSendMsg = servSendMsg;
|
||||||
|
_servNotification = servNotification;
|
||||||
}
|
}
|
||||||
[HttpPost("authenticate")]
|
[HttpPost("authenticate")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -92,6 +94,15 @@ namespace Back.Controllers
|
|||||||
return Ok(await _servUser.GetDashBoard(Convert.ToInt32(UserID)));
|
return Ok(await _servUser.GetDashBoard(Convert.ToInt32(UserID)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpPut("ReadNotification/{ntID}")]
|
||||||
|
public async Task<ActionResult<bool>> 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));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ namespace TaxPayer.Infrastructure.Persistence
|
|||||||
public DbSet<OrderDiscountCode> OrderDiscountCodes { get; set; }
|
public DbSet<OrderDiscountCode> OrderDiscountCodes { get; set; }
|
||||||
public DbSet<TiceketUnknownPeople> TiceketUnknownPeoples { get; set; }
|
public DbSet<TiceketUnknownPeople> TiceketUnknownPeoples { get; set; }
|
||||||
public DbSet<SaleLead> SaleLeads { get; set; }
|
public DbSet<SaleLead> SaleLeads { get; set; }
|
||||||
|
public DbSet<UserNotfi> UserNotifis { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
//public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
//public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
//{
|
//{
|
||||||
|
@@ -5,9 +5,10 @@
|
|||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public int Type { get; set; }
|
public int Type { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public string? Path { get; set; }
|
public string Title { get; set; }
|
||||||
public string? ViewSize { get; set; }
|
|
||||||
public string Date { get; set; }
|
public string Date { get; set; }
|
||||||
public bool Status { get; set; }
|
public int Status { get; set; }
|
||||||
|
public string? ForUser { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
Back/Data/Models/UserNotfi.cs
Normal file
9
Back/Data/Models/UserNotfi.cs
Normal file
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
@@ -7,14 +7,27 @@ namespace Back.Services
|
|||||||
public class servNotification
|
public class servNotification
|
||||||
{
|
{
|
||||||
private readonly IAsyncRepository<Notification> _NotificationRepo;
|
private readonly IAsyncRepository<Notification> _NotificationRepo;
|
||||||
|
private readonly IAsyncRepository<UserNotfi> _UserNotfiRepo;
|
||||||
public servNotification(IAsyncRepository<Notification> NotificationRepo)
|
public servNotification(IAsyncRepository<Notification> NotificationRepo, IAsyncRepository<UserNotfi> userNotfiRepo)
|
||||||
{
|
{
|
||||||
_NotificationRepo = NotificationRepo;
|
_NotificationRepo = NotificationRepo;
|
||||||
|
_UserNotfiRepo = userNotfiRepo;
|
||||||
}
|
}
|
||||||
public async Task<List<Notification>> GetNotifications()
|
public async Task<bool> 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<List<Notification>> 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -244,14 +244,14 @@ namespace Back.Services
|
|||||||
request.Warning.Add(new AlertDTO { Status = 5, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
|
request.Warning.Add(new AlertDTO { Status = 5, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var nots = await _servNotification.GetNotifications();
|
var nots = await _servNotification.GetNotifications(UserID);
|
||||||
if (nots.Any())
|
if (nots.Any())
|
||||||
request.Notifications = nots.Select(s => new AlertDTO
|
request.Notifications = nots.Select(s => new AlertDTO
|
||||||
{
|
{
|
||||||
|
ViewSize=s.ID.ToString(),
|
||||||
Message = s.Message,
|
Message = s.Message,
|
||||||
Status = s.Type,
|
Status = s.Type,
|
||||||
Path = s.Path,
|
Path = s.Title
|
||||||
ViewSize = s.ViewSize
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
LastActivitySevice lastInvoice = new LastActivitySevice();
|
LastActivitySevice lastInvoice = new LastActivitySevice();
|
||||||
|
@@ -1,11 +1,25 @@
|
|||||||
@using Shared.DTOs
|
@using Front.Services
|
||||||
<h3>Notifications</h3>
|
@using Shared.DTOs
|
||||||
<h3>@items.Count()</h3>
|
@inject HttpClientController hc;
|
||||||
|
@inject Fixedvalues fv;
|
||||||
|
@foreach (var item in items)
|
||||||
|
{
|
||||||
|
<Alert OnClosed="()=>OnClosedAlert(item)" Color="(AlertColor)Enum.Parse(typeof(AlertColor), item.Status.ToString())" Dismissable="true"> @item.Message </Alert>
|
||||||
|
}
|
||||||
|
|
||||||
<Alert Color="AlertColor.Warning" Dismissable="true"> <strong>Holy guacamole!</strong> You should check in on some of those fields below. </Alert>
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[Parameter] public List<AlertDTO> items { get; set; }
|
[Parameter] public List<AlertDTO> 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);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -166,11 +166,15 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<!--/ User -->
|
<!--/ User -->
|
||||||
<li class="nav-item lh-1 me-3 f-ir">
|
@if (dashBoard?.Notifications.Count()>0)
|
||||||
<Button Type="ButtonType.Button" @onclick="ShowNotifications" Color="ButtonColor.None">
|
{
|
||||||
<Badge Color="BadgeColor.Danger"><Icon Name="IconName.MegaphoneFill" /> @dashBoard?.Notifications.Count()</Badge>
|
<li class="nav-item lh-1 me-3 f-ir">
|
||||||
</Button>
|
<Button Type="ButtonType.Button" @onclick="ShowNotifications" Color="ButtonColor.None">
|
||||||
</li>
|
<Badge Color="BadgeColor.Danger"><Icon Name="IconName.MegaphoneFill" /> @dashBoard?.Notifications.Count()</Badge>
|
||||||
|
</Button>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -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");
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user