This commit is contained in:
mmrbnjd
2024-06-25 20:54:16 +03:30
parent ce81911242
commit 75b9644151
3 changed files with 21 additions and 9 deletions

View File

@@ -12,14 +12,18 @@
@code { @code {
[Parameter] public List<AlertDTO> items { get; set; } [Parameter] public List<AlertDTO> items { get; set; }
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
public async Task OnClosedAlert(AlertDTO nt) public async Task OnClosedAlert(AlertDTO nt)
{ {
var rsp= await hc.Put($"User/ReadNotification/{Convert.ToInt32(nt.ViewSize)}"); var rsp= await hc.Put($"User/ReadNotification/{Convert.ToInt32(nt.ViewSize)}");
// if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)
// { {
// fv.dashBoard.Notifications.Remove(nt); var ddd= fv.dashBoard?.Notifications.Remove(fv.dashBoard?.Notifications.Where(w=>w.ViewSize==nt.ViewSize&&w.Status==nt.Status
&&w.Path==nt.Path&&w.Message==nt.Message).First());
// } await OnMultipleOfThree.InvokeAsync(fv.dashBoard.Notifications.Count());
}
} }
} }

View File

@@ -14,7 +14,7 @@ namespace Front
private List<CODIdName<int>>? Cods = null; private List<CODIdName<int>>? Cods = null;
private CompanyDTO? InfoCompany = null; private CompanyDTO? InfoCompany = null;
public InvoiceDTO? invoice { get; set; } = null; public InvoiceDTO? invoice { get; set; } = null;
private DashBoardDTO? dashBoard { get; set; } = null; public DashBoardDTO? dashBoard { get; set; } = null;
public Fixedvalues(HttpClientController hc) public Fixedvalues(HttpClientController hc)
{ {
_hc = hc; _hc = hc;
@@ -76,10 +76,10 @@ namespace Front
return InfoCompany; return InfoCompany;
} }
public async Task<DashBoardDTO?> GetDashBoard() public async Task<DashBoardDTO?> GetDashBoard(bool run=false)
{ {
if (dashBoard == null) if (dashBoard == null || run)
{ {
var rsp = await _hc.Get("User/GetDashBoard"); var rsp = await _hc.Get("User/GetDashBoard");
if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)

View File

@@ -170,7 +170,7 @@
{ {
<li class="nav-item lh-1 me-3 f-ir"> <li class="nav-item lh-1 me-3 f-ir">
<Button Type="ButtonType.Button" @onclick="ShowNotifications" Color="ButtonColor.None"> <Button Type="ButtonType.Button" @onclick="ShowNotifications" Color="ButtonColor.None">
<Badge Color="BadgeColor.Danger"><Icon Name="IconName.MegaphoneFill" /> @dashBoard?.Notifications.Count()</Badge> <Badge Color="BadgeColor.Danger"><Icon Name="IconName.MegaphoneFill" /> @countnot</Badge>
</Button> </Button>
</li> </li>
} }
@@ -216,6 +216,7 @@
</div> </div>
@code { @code {
public int countnot = 0;
private Modal modal = default!; private Modal modal = default!;
public DashBoardDTO? dashBoard { get; set; } public DashBoardDTO? dashBoard { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@@ -224,15 +225,22 @@
nav.NavigateTo("/"); nav.NavigateTo("/");
dashBoard = await fv.GetDashBoard(); dashBoard = await fv.GetDashBoard();
if (dashBoard != null)
countnot = dashBoard.Notifications.Count();
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
} }
@functions { @functions {
public async Task CallBack(int count)
{
countnot = count;
}
public async Task ShowNotifications() public async Task ShowNotifications()
{ {
// dashBoard = await fv.GetDashBoard();
var parameters = new Dictionary<string, object>(); var parameters = new Dictionary<string, object>();
parameters.Add("items", dashBoard?.Notifications); parameters.Add("items", dashBoard?.Notifications);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<int>(this, CallBack));
await modal.ShowAsync<Front.CUSComponent.Notifications>(title: "اطلاعیه ها", parameters: parameters); await modal.ShowAsync<Front.CUSComponent.Notifications>(title: "اطلاعیه ها", parameters: parameters);