2025-07-11 20:37:28 +03:30
|
|
|
|
@page "/UserManagement"
|
|
|
|
|
<ConfirmDialog @ref="dialog" />
|
2025-07-12 21:33:44 +03:30
|
|
|
|
@using Common.Dtos.Exper
|
2025-07-11 20:37:28 +03:30
|
|
|
|
@using HushianWebApp.Components
|
|
|
|
|
@using HushianWebApp.Service
|
|
|
|
|
@using HushianWebApp.Services
|
|
|
|
|
@inject ILocalStorageService localStorageService;
|
|
|
|
|
@inject NavigationManager navigationManager;
|
|
|
|
|
@inject UserService userService;
|
|
|
|
|
<Modal @ref="modal" />
|
|
|
|
|
|
|
|
|
|
<Button Color="ButtonColor.Success" Style="margin-bottom:10px"
|
|
|
|
|
@onclick="async()=>{
|
|
|
|
|
await modal.ShowAsync<ADDExperComponent>(title,parameters:parameters);
|
|
|
|
|
}">
|
|
|
|
|
کارشناس جدید
|
|
|
|
|
</Button>
|
|
|
|
|
|
2025-07-12 21:33:44 +03:30
|
|
|
|
<Grid @ref="grid" TItem="Read_ExperDto"
|
2025-07-11 20:37:28 +03:30
|
|
|
|
AllowSorting="true"
|
|
|
|
|
Class="table table-hover"
|
|
|
|
|
DataProvider="DataProvider"
|
|
|
|
|
HeaderRowCssClass="bg-primary text-white bg-opacity-75 border-bottom-0"
|
|
|
|
|
Responsive="true"
|
|
|
|
|
AllowPaging="true"
|
|
|
|
|
OnRowDoubleClick="OnRowClick"
|
|
|
|
|
AllowRowClick=true>
|
|
|
|
|
|
|
|
|
|
<GridColumns>
|
2025-07-12 21:33:44 +03:30
|
|
|
|
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="نام کاریری" SortKeySelector="item => item.UserName">
|
2025-07-11 20:37:28 +03:30
|
|
|
|
@context.UserName
|
|
|
|
|
</GridColumn>
|
|
|
|
|
|
2025-07-12 21:33:44 +03:30
|
|
|
|
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="نام کامل" SortKeySelector="item => item.FullName">
|
2025-07-11 20:37:28 +03:30
|
|
|
|
@context.FullName
|
|
|
|
|
</GridColumn>
|
|
|
|
|
|
2025-07-25 21:29:57 +03:30
|
|
|
|
|
2025-07-11 20:37:28 +03:30
|
|
|
|
|
2025-07-12 21:33:44 +03:30
|
|
|
|
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="وضعیت">
|
2025-07-11 20:37:28 +03:30
|
|
|
|
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
|
|
|
|
|
|
|
|
|
|
</GridColumn>
|
2025-07-12 21:33:44 +03:30
|
|
|
|
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="عملیات">
|
|
|
|
|
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteExper(context.ID,context.FullName)"> حذف </Button>
|
|
|
|
|
<Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.ID,context.FullName)"> گروه ها </Button>
|
2025-07-11 20:37:28 +03:30
|
|
|
|
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridColumns>
|
|
|
|
|
|
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
private ConfirmDialog dialog = default!;
|
|
|
|
|
|
|
|
|
|
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
2025-07-12 21:33:44 +03:30
|
|
|
|
Grid<Read_ExperDto> grid = default!;
|
2025-07-25 21:29:57 +03:30
|
|
|
|
public List<Read_ExperDto> list = new();
|
2025-07-11 20:37:28 +03:30
|
|
|
|
private Modal modal = default!;
|
|
|
|
|
string title = "کارشناس جدید";
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
|
|
|
|
|
2025-07-25 21:29:57 +03:30
|
|
|
|
if (await localStorageService.GetItem<string>("C/Role")!= "Company" )
|
2025-07-11 20:37:28 +03:30
|
|
|
|
navigationManager.NavigateTo("/NotFound");
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
2025-07-12 21:33:44 +03:30
|
|
|
|
private async Task<GridDataProviderResult<Read_ExperDto>> DataProvider(GridDataProviderRequest<Read_ExperDto> request)
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
2025-07-25 21:29:57 +03:30
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
list = await userService.GetExpersCompany();
|
|
|
|
|
|
|
|
|
|
int skip = (request.PageNumber - 1) * request.PageSize;
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(request.ApplyTo(list != null ? list.Skip(skip).Take(request.PageSize).ToList() : new()));
|
2025-07-11 20:37:28 +03:30
|
|
|
|
}
|
|
|
|
|
async Task CallBack()
|
|
|
|
|
{
|
|
|
|
|
await modal.HideAsync();
|
|
|
|
|
await grid.RefreshDataAsync();
|
|
|
|
|
}
|
2025-07-12 21:33:44 +03:30
|
|
|
|
private async Task OnRowClick(GridRowEventArgs<Read_ExperDto> args)
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
2025-07-12 21:33:44 +03:30
|
|
|
|
var editmodel = new Update_ExperDto()
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
2025-07-12 21:33:44 +03:30
|
|
|
|
FullName = args.Item.FullName
|
2025-07-11 20:37:28 +03:30
|
|
|
|
};
|
|
|
|
|
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
|
|
|
|
eparameters.Add("model", editmodel);
|
2025-07-22 19:05:57 +03:30
|
|
|
|
eparameters.Add("ExperID", args.Item.ID);
|
2025-07-11 20:37:28 +03:30
|
|
|
|
eparameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
|
|
|
|
|
|
|
|
|
await modal.ShowAsync<UpdateExperComponent>($"ویرایش کارشناس {args.Item.FullName}", parameters: eparameters);
|
|
|
|
|
|
|
|
|
|
}
|
2025-07-12 21:33:44 +03:30
|
|
|
|
private async Task SwitchChanged(Read_ExperDto model, bool value)
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
|
|
|
|
if (model.Available != value)
|
|
|
|
|
{
|
2025-07-12 21:33:44 +03:30
|
|
|
|
if (await userService.ChangeAvailableExperFromManager(model.ID, value))
|
2025-07-11 20:37:28 +03:30
|
|
|
|
model.Available = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-07-12 21:33:44 +03:30
|
|
|
|
private async Task DeleteExper(int ExperID,string name)
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
|
|
|
|
var confirmation = await dialog.ShowAsync(
|
|
|
|
|
title: $"مطمئنی میخوای {name} حذف کنی؟",
|
|
|
|
|
message1: "پس از حذف، نمیتوان آن را به حالت اولیه برگرداند.",
|
|
|
|
|
message2: "میخوای ادامه بدی؟",new ConfirmDialogOptions()
|
|
|
|
|
{
|
|
|
|
|
YesButtonColor=ButtonColor.Danger,
|
|
|
|
|
YesButtonText="بله",
|
|
|
|
|
NoButtonText="نه !"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!confirmation) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await userService.DeleteExperFromManager(ExperID))
|
|
|
|
|
await grid.RefreshDataAsync();
|
|
|
|
|
}
|
|
|
|
|
private string GetImageSource(byte[]? img)
|
|
|
|
|
{
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
return $"data:image/jpeg;base64,{Convert.ToBase64String(img)}";
|
|
|
|
|
}
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
2025-07-12 21:33:44 +03:30
|
|
|
|
async Task showGroupsComponent(int ExperID, string name)
|
2025-07-11 20:37:28 +03:30
|
|
|
|
{
|
|
|
|
|
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
|
|
|
|
eparameters.Add("ExperID", ExperID);
|
|
|
|
|
|
|
|
|
|
modal.Size = ModalSize.Small;
|
|
|
|
|
await modal.ShowAsync<UserGroupsComponent>($"گروه های کارشناس {name}", parameters: eparameters);
|
|
|
|
|
}
|
|
|
|
|
}
|