This commit is contained in:
mmrbnjd
2025-07-12 21:33:44 +03:30
parent d397f70b9a
commit 8a6ff3da67
32 changed files with 320 additions and 403 deletions

View File

@@ -1,7 +1,7 @@
@using Common.Dtos.User
@using Hushian.Application.Dtos
@using Common.Dtos.Exper
@using HushianWebApp.Service
@using HushianWebApp.Services
@using Common.Validation
@inject UserService userService;
<div class="row" style="height: fit-content; padding: 1rem;">
@@ -13,21 +13,11 @@
</div>
<div class="col-md-12">
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.PhoneNumber" type="text" class="form-control" placeholder="موبایل" />
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Password" type="password" class="form-control" placeholder="کلمه عبور" />
</div>
<div class="col-md-12">
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
</div>
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
@if (model.img != null && model.img.Length > 0)
{
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
}
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@RePassword" type="password" class="form-control" placeholder="تکرار کلمه عبور" />
</div>
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button>
@@ -36,18 +26,43 @@
@code {
public AddUserDto model { get; set; } = new();
[Inject] protected ToastService ToastService { get; set; } = default!;
public ADD_ExperDto model { get; set; } = new();
public string RePassword { get; set; }
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}
@functions{
@functions {
async Task<bool> Validation()
{
if (string.IsNullOrEmpty(model.FullName))
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را مشخص کنید"));
return false;
}
if (!model.FullName.IsOnlyPersianLetters())
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return false;
}
if (model.Password!=RePassword)
{
ToastService.Notify(new(ToastType.Danger, $"کلمه عبور و تکرار آن مشابه نیستند"));
return false;
}
List<string> errors = new();
if (!model.Password.CheckLawPassword(ref errors))
{
ToastService.Notify(new(ToastType.Danger, errors.First()));
return false;
}
return true;
}
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.FullName) && !string.IsNullOrEmpty(model.PhoneNumber))
if (await Validation())
{
model.PassWord =model.UserName= model.PhoneNumber;
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
loading = true;
if (await userService.AddExper(model))
{
@@ -60,23 +75,23 @@
protected override async Task OnParametersSetAsync()
{
model = new();
await base.OnParametersSetAsync();
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
model.img = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (model.img != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
}
return string.Empty;
await base.OnParametersSetAsync();
}
// private async Task OnFileChange(InputFileChangeEventArgs e)
// {
// var file = e.File;
// using (var memoryStream = new MemoryStream())
// {
// await file.OpenReadStream().CopyToAsync(memoryStream);
// model.img = memoryStream.ToArray();
// }
// }
// private string GetImageSource()
// {
// if (model.img != null)
// {
// return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
// }
// return string.Empty;
// }
}

View File

@@ -1,4 +1,4 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Group
@using HushianWebApp.Service
@inject GroupService groupService;
<div class="row" style="height: fit-content; padding: 1rem;">
@@ -27,7 +27,7 @@
</div>
@code {
[Parameter] public ADDGroupDto model { get; set; } = new();
[Parameter] public ADD_GroupDto model { get; set; } = new();
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}

View File

@@ -1,30 +1,30 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Conversation
@inject IJSRuntime JSRuntime
<div class="chat-container p-3">
@foreach (var msg in Messages)
{
@if (!target && ((!msg.IsRead && msg.Type == Hushian.Enums.ConversationType.UE) || Messages.Last() == msg))
@if (!target && ((!msg.IsRead && msg.Type == Common.Enums.ConversationType.UE) || Messages.Last() == msg))
{
target = true;
<div id="target" style="text-align: center;">
@if (!msg.IsRead && msg.Type == Hushian.Enums.ConversationType.UE)
@if (!msg.IsRead && msg.Type == Common.Enums.ConversationType.UE)
{
<p>ـــــــــــــــــــــــــ</p>
}
</div>
}
<div class="d-flex mb-2 @(msg.Type==Hushian.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")" >
<div class="chat-bubble @(msg.Type==Hushian.Enums.ConversationType.UE ? "chat-mine"
: msg.Type==Hushian.Enums.ConversationType.UE && msg.ExperID=="bot" ? "chat-ai" : "chat-other")" data-id="@msg.ID">
<div class="d-flex mb-2 @(msg.Type==Common.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")">
<div class="chat-bubble @(msg.Type==Common.Enums.ConversationType.UE ? "chat-mine"
: "chat-other")" data-id="@msg.ID">
@msg.text
</div>
@if (msg.Type == Hushian.Enums.ConversationType.EU)
@if (msg.Type == Common.Enums.ConversationType.EU)
{
if (msg.IsRead)
{
@@ -75,7 +75,7 @@
@code {
bool target = false;
[Parameter]
public List<ConversationItemDto> Messages { get; set; } = new();
public List<Read_ConversationResponseDto> Messages { get; set; } = new();
[Parameter] public EventCallback<int> EventCallIsRead { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
@@ -91,7 +91,7 @@
public async Task MarkAsRead(int id)
{
var msg = Messages.FirstOrDefault(m => m.ID == id);
if (msg != null && !msg.IsRead && msg.Type==Hushian.Enums.ConversationType.UE)
if (msg != null && !msg.IsRead && msg.Type==Common.Enums.ConversationType.UE)
{
msg.IsRead = true;
await EventCallIsRead.InvokeAsync(id);

View File

@@ -1,4 +1,5 @@
@using Common.Dtos.User
@using Common.Dtos
@using Common.Validation
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject UserService userService;
@@ -8,11 +9,11 @@
<form style="background-color: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column;">
<label style="margin-bottom: 8px; font-size: 14px; color: #333;" for="oldpass">رمز عبور قبلی:</label>
<input dir="ltr" style="text-align:center" @bind="@dto.OldPassword" type="password" class="form-control" placeholder="رمز عبور قبلی" />
<input dir="ltr" style="text-align:center" @bind="@dto.OldPassWord" type="password" class="form-control" placeholder="رمز عبور قبلی" />
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass">رمز عبور جدید:</label>
<input dir="ltr" style="text-align:center" @bind="@dto.NewPassword" type="password" class="form-control" placeholder="رمز عبور جدید" />
<input dir="ltr" style="text-align:center" @bind="@dto.NewPassWord" type="password" class="form-control" placeholder="رمز عبور جدید" />
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass2">تکرار رمز عبور جدید:</label>
<input dir="ltr" style="text-align:center" @bind="RePassword" type="password" class="form-control" placeholder="تکرار رمز عبور جدید" />
@@ -31,25 +32,33 @@
@code {
[Inject] protected ToastService ToastService { get; set; } = default!;
public bool SpinnerVisible { get; set; }
public ChangePasswordFromUserDto dto { get; set; } = new();
public ChangePasswordDto dto { get; set; } = new();
public string RePassword { get; set; } = "";
public string Username { get; set; } = "";
protected override async Task OnParametersSetAsync()
{
Username = await localStorageService.GetItem<string>("Username");
dto = new() { UserName = Username };
// Username = await localStorageService.GetItem<string>("Username");
// dto = new() { UserName = Username };
await base.OnParametersSetAsync();
}
async Task Click()
{
if (string.IsNullOrEmpty(dto.OldPassword) || string.IsNullOrEmpty(dto.NewPassword))
if (string.IsNullOrEmpty(dto.OldPassWord) || string.IsNullOrEmpty(dto.NewPassWord))
return;
if (dto.NewPassword != RePassword)
if (dto.NewPassWord != RePassword)
{
ToastService.Notify(new ToastMessage(ToastType.Danger, "کلمه عبور با تکرار متفاوت است"));
return;
}
List<string> errors = new();
if (!dto.NewPassWord.CheckLawPassword(ref errors))
{
ToastService.Notify(new(ToastType.Danger, errors.First()));
return ;
}
SpinnerVisible = true;
var result = await userService.ChangePasswordYourself(dto);
if (result)

View File

@@ -1,4 +1,5 @@
@using Common.Dtos.User
@using Common.Dtos.Exper
@using Common.Validation
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject UserService userService;
@@ -10,48 +11,29 @@
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام کامل" />
</div>
<div class="col-md-12">
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
</div>
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
@if (model.img != null && model.img.Length > 0)
{
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
}
</div>
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
@if (isAuthorizedCompanyUser)
{
<Button Loading=loading LoadingText="در حال آزادسازی..." Color="ButtonColor.Danger" @onclick="FreeExper"> آزادسازی کارشناس </Button>
}
</div>
@code {
bool isAuthorizedCompanyUser = false;
[Parameter] public EventCallback<EditUserFromUserDto> OnMultipleOfThree { get; set; }
public List<string> Roles { get; set; } = new();
[Parameter] public EventCallback<Update_ExperDto> OnMultipleOfThree { get; set; }
public string Role { get; set; }
public bool loading { get; set; } = false;
[Inject] protected ToastService ToastService { get; set; } = default!;
public EditUserFromUserDto model { get; set; } = new();
public Update_ExperDto model { get; set; } = new();
protected override async Task OnInitializedAsync()
{
var user=await userService.GetCurrentUser();
if (user!=null)
{
model.UserName=user.UserName;
model.img = user.img;
model.FullName = user.FullName;
model.Email = user.Email;
Roles = await localStorageService.GetItem<List<string>>("Role");
isAuthorizedCompanyUser = Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany();
Role = await localStorageService.GetItem<string>("Role");
isAuthorizedCompanyUser = Role=="Exper" && await userService.CheckAvailableExperInCompany();
}
else
{
@@ -59,30 +41,16 @@
}
await base.OnInitializedAsync();
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
model.img = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (model.img != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
}
return string.Empty;
}
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.FullName))
{
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
if (!model.FullName.IsOnlyPersianLetters())
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return;
}
loading = true;
if (await userService.EditUserYourself(model))
{
@@ -92,15 +60,5 @@
loading = false;
}
}
async Task FreeExper()
{
loading = true;
if (await userService.FreeExper())
{
loading = false;
await OnMultipleOfThree.InvokeAsync(model);
}
loading = false;
}
}

View File

@@ -1,4 +1,4 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Exper
@using HushianWebApp.Service
@inject GroupService groupService;
@inject UserService userService;
@@ -7,14 +7,14 @@
<div class="row">
<div class="col-md-12 col-sm-12" style="margin-bottom:15px">
<AutoComplete @bind-Value="ExperName"
TItem="HushianUserDto"
TItem="Read_ExperDto"
DataProvider="DataProvider"
PropertyName="FullName"
Placeholder="جستجو در کاربران..."
OnChanged="(HushianUserDto exper) => OnAutoCompleteChanged(exper)" />
OnChanged="(Read_ExperDto exper) => OnAutoCompleteChanged(exper)" />
</div>
</div>
<SortableList TItem="HushianUserDto"
<SortableList TItem="Read_ExperDto"
Data="Expers"
Context="item"
AllowSorting="false">
@@ -37,9 +37,9 @@
private bool Spinnervisible = false;
[Parameter] public int GroupID { get; set; }
public List<HushianUserDto> Expers { get; set; }
public List<Read_ExperDto> Expers { get; set; }
= new();
public List<HushianUserDto> CoExpers { get; set; }
public List<Read_ExperDto> CoExpers { get; set; }
= new();
protected override async Task OnParametersSetAsync()
{
@@ -50,25 +50,25 @@
}
}
@functions {
private async Task<AutoCompleteDataProviderResult<HushianUserDto>> DataProvider(AutoCompleteDataProviderRequest<HushianUserDto> request)
private async Task<AutoCompleteDataProviderResult<Read_ExperDto>> DataProvider(AutoCompleteDataProviderRequest<Read_ExperDto> request)
{
CoExpers = (await userService.GetExpersCompany(0, 0, 0)).list;
return await Task.FromResult(new AutoCompleteDataProviderResult<HushianUserDto> { Data = CoExpers.Where(w => w.FullName.Contains(request.Filter.Value)), TotalCount = CoExpers.Count() });
CoExpers = await userService.GetExpersCompany(0, 0, 0);
return await Task.FromResult(new AutoCompleteDataProviderResult<Read_ExperDto> { Data = CoExpers.Where(w => w.FullName.Contains(request.Filter.Value)), TotalCount = CoExpers.Count() });
}
private async Task OnAutoCompleteChanged(HushianUserDto exper)
private async Task OnAutoCompleteChanged(Read_ExperDto exper)
{
Spinnervisible = true;
if (exper != null
&& !Expers.Any(a => a.UserID == exper.UserID)
&& await groupService.JoinExperToGroup(GroupID, exper.UserID) )
&& !Expers.Any(a => a.ID == exper.ID)
&& await groupService.JoinExperToGroup(GroupID, exper.ID) )
Expers.Add(exper);
Spinnervisible = false;
}
async Task UnJoin(HushianUserDto exper)
async Task UnJoin(Read_ExperDto exper)
{
Spinnervisible = true;
if (exper != null && await groupService.UnJoinExperToGroup(GroupID, exper.UserID))
if (exper != null && await groupService.UnJoinExperToGroup(GroupID, exper.ID))
Expers.Remove(exper);
Spinnervisible = false;
}

View File

@@ -1,7 +1,8 @@
@using Common.Dtos.User
@using Hushian.Application.Dtos

@using Common.Dtos.Exper
@using HushianWebApp.Service
@using HushianWebApp.Services
@using Common.Validation
@inject UserService userService;
<div class="row" style="height: fit-content; padding: 1rem;">
@@ -11,20 +12,7 @@
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام و نام خانوادگی" />
</div>
<div class="col-md-12">
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
</div>
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
@if (model.img != null && model.img.Length > 0)
{
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
}
</div>
<Button Loading=loading LoadingText="در حال ویرایش اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
@@ -32,7 +20,9 @@
@code {
[Parameter] public EditUserFromUserDto model { get; set; }
[Inject] protected ToastService ToastService { get; set; } = default!;
[Parameter] public Update_ExperDto model { get; set; }
[Parameter] public int ExperID { get; set; }
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}
@@ -41,10 +31,13 @@
{
if (!string.IsNullOrEmpty(model.FullName))
{
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
if (!model.FullName.IsOnlyPersianLetters())
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return ;
}
loading = true;
if (await userService.ExperEditingFromManager(model))
if (await userService.ExperEditingFromManager(ExperID,model))
{
loading = false;
await OnMultipleOfThree.InvokeAsync();
@@ -53,21 +46,5 @@
}
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
model.img = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (model.img != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
}
return string.Empty;
}
}

View File

@@ -1,4 +1,4 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Group
@using HushianWebApp.Service
@inject GroupService groupService;
<div class="row" style="height: fit-content; padding: 1rem;">
@@ -28,7 +28,7 @@
</div>
@code {
[Parameter] public GroupDto model { get; set; }
[Parameter] public Update_GroupDto model { get; set; }
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}

View File

@@ -1,4 +1,5 @@
@using Hushian.Application.Dtos

@using Common.Dtos.Group
@using HushianWebApp.Service
@inject GroupService groupService;
@@ -7,14 +8,14 @@
<div class="row">
<div class="col-md-12 col-sm-12" style="margin-bottom:15px">
<AutoComplete @bind-Value="GroupName"
TItem="GroupDto"
TItem="Read_GroupDto"
DataProvider="DataProvider"
PropertyName="Name"
Placeholder="جستجو در گروه ها..."
OnChanged="(GroupDto group) => OnAutoCompleteChanged(group)" />
OnChanged="(Read_GroupDto group) => OnAutoCompleteChanged(group)" />
</div>
</div>
<SortableList TItem="GroupDto"
<SortableList TItem="Read_GroupDto"
Data="Groups"
Context="item"
AllowSorting="false">
@@ -35,10 +36,10 @@
private string? GroupName;
private bool Spinnervisible = false;
[Parameter] public string ExperID { get; set; }
public List<GroupDto> Groups { get; set; }
[Parameter] public int ExperID { get; set; }
public List<Read_GroupDto> Groups { get; set; }
= new();
public List<GroupDto> CoGroups { get; set; }
public List<Read_GroupDto> CoGroups { get; set; }
= new();
protected override async Task OnParametersSetAsync()
{
@@ -49,13 +50,13 @@
}
}
@functions {
private async Task<AutoCompleteDataProviderResult<GroupDto>> DataProvider(AutoCompleteDataProviderRequest<GroupDto> request)
private async Task<AutoCompleteDataProviderResult<Read_GroupDto>> DataProvider(AutoCompleteDataProviderRequest<Read_GroupDto> request)
{
CoGroups = await groupService.GetGroupsCompany();
return await Task.FromResult(new AutoCompleteDataProviderResult<GroupDto> { Data = CoGroups.Where(w=>w.Name.Contains(request.Filter.Value)), TotalCount = CoGroups.Count() });
return await Task.FromResult(new AutoCompleteDataProviderResult<Read_GroupDto> { Data = CoGroups.Where(w => w.Name.Contains(request.Filter.Value)), TotalCount = CoGroups.Count() });
}
private async Task OnAutoCompleteChanged(GroupDto group)
private async Task OnAutoCompleteChanged(Read_GroupDto group)
{
Spinnervisible = true;
if (group != null
@@ -64,7 +65,7 @@
Groups.Add(group);
Spinnervisible = false;
}
async Task UnJoin(GroupDto group)
async Task UnJoin(Read_GroupDto group)
{
Spinnervisible = true;
if (group != null && await groupService.UnJoinExperToGroup(group.ID, ExperID))

View File

@@ -1,4 +1,5 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Conversation
<small>پیام های اخیر شما ...</small>
<div class="row">
@foreach (var item in Conversations)
@@ -6,13 +7,13 @@
<div class="col-sm-3">
<Card>
<CardBody>
<CardText>@GetTitleCon(item.Title)</CardText>
<CardText>@GetTitleCon(item.LastText)</CardText>
<Button Color="ButtonColor.Primary" @onclick="async()=>await OnMultipleOfThree.InvokeAsync(item.ID)" Type="ButtonType.Link">Go somewhere</Button>
</CardBody>
<ul class="list-group list-group-flush">
<li class="list-group-item">@item.ExperFullName (@item.Cdate item.Ctime)</li>
<li class="list-group-item">@item.ExperFullName (@item.LastMsgdate @item.LastMsgtime)</li>
</ul>
@if (item.status == Hushian.Enums.ConversationStatus.InProgress && item.NoReadCount > 0)
@if (item.status == Common.Enums.ConversationStatus.InProgress && item.NoReadCount > 0)
{
<Badge Color="BadgeColor.Danger"
Position="Position.Absolute"
@@ -31,7 +32,7 @@
@code {
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
[Parameter] public List<ConversationDto> Conversations { get; set; }
[Parameter] public List<Read_ConversationDto> Conversations { get; set; }
string GetTitleCon(string str)
{
if (str.Length > 15) return str.Substring(0, 15) + "...";

View File

@@ -1,4 +1,5 @@
@using Common.Dtos.User

@using Common.Dtos.Verification
@using Common.Enums
@using HushianWebApp.Service
@inject VerificationService verificationService;

View File

@@ -1,5 +1,5 @@
@inherits LayoutComponentBase
@using Common.Dtos.User
@using Common.Dtos.Exper
@using HushianWebApp.Components
@using HushianWebApp.Pages
@using HushianWebApp.Pages.Manage
@@ -93,9 +93,9 @@
}
TitleRole = Roles.Any(a => a == "HushianManagerCompany") ? "مدیر" : "کارشناس";
TitleRole = Roles.Any(a => a == "Company") ? "مدیر" : "کارشناس";
isAuthorizedCompanyUser = Roles.Contains("HushianManagerCompany") || (Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany());
isAuthorizedCompanyUser = Roles.Contains("Company") || (Roles.Contains("Exper") && await userService.CheckAvailableExperInCompany());
string route = NavigationManager.Uri.Replace(NavigationManager.BaseUri, "").ToLower();
if (route.Length > 0)
@@ -136,17 +136,16 @@
private async Task EditCurrentUser()
{
var parameters = new Dictionary<string, object>();
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<EditUserFromUserDto>(this, CallBack));
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<Update_ExperDto>(this, CallBack));
await modal.ShowAsync<EditUserYourselfComponent>(title: $"ویرایش کاربر {Username}", parameters: parameters);
}
async Task CallBack(EditUserFromUserDto edit)
async Task CallBack(Update_ExperDto edit)
{
await modal.HideAsync();
img = edit.img;
await localStorageService.RemoveItem("img");
await localStorageService.SetItem("img", img);
// await localStorageService.RemoveItem("img");
// await localStorageService.SetItem("img", img);
Fullname = edit.FullName;
await localStorageService.RemoveItem("Fullname");

View File

@@ -0,0 +1,8 @@
namespace HushianWebApp.Models
{
public class WindowSize
{
public int Width { get; set; }
public int Height { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
@page "/Login"
@using Common.Enums
@using Common.Models.Identity
@using Common.Models.Auth.CompanySide
@using HushianWebApp.Components
@using HushianWebApp.Service
@layout BeforeLayout
@@ -11,7 +11,7 @@
<ConfirmDialog @ref="dialog" />
<div class="header-form">
<img src="/before/assets/images/Hushian-logo.svg" width="133" alt="Hushian" class="lg:hidden mb-3">
<img src="/before/assets/images/Hushian-logo.svg" width="133" alt="Hushian" class="lg:hidden mb-3">
<span>ورود</span>
<span>به هوشیان</span>
@@ -59,7 +59,7 @@
</div>
<div class=" space-y-5 flex flex-col items-center">
<NavLink class="btn btn-outline w-full mb-4 lg:mb-0" href="Register">
ثبت نام
ثبت نام
</NavLink>
</div>
@@ -77,27 +77,32 @@
@functions {
async Task onClick()
{
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(Password)) return;
Loading = true;
var msg = await auth.login(new AuthRequest(username, Password));
if (msg == "PhoneNumberNotConfirmed")
{
var confirmation = await dialog.ShowAsync(
title: "احراز کاربری",
message1: "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید",
message2: "انجام بدیم؟");
if (!confirmation)
var msg = await auth.login(new AuthRequestFromCompanySide()
{
Loading = false;
return;
}
await verification();
}
else if (msg == "ok")
Username = username,
Password = Password
});
// if (msg == "PhoneNumberNotConfirmed")
// {
// var confirmation = await dialog.ShowAsync(
// title: "احراز کاربری",
// message1: "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید",
// message2: "انجام بدیم؟");
// if (!confirmation)
// {
// Loading = false;
// return;
// }
// await verification();
// }
// else
if (msg == "ok")
{
navigationManager.NavigateTo("/");
}
@@ -106,19 +111,19 @@
Loading = false;
}
async Task verification()
{
var parameters = new Dictionary<string, object>();
parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed);
parameters.Add("sendValue", username);
parameters.Add("ID", 0);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<VerificationCodeType>(this, CallBackVer));
parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید");
await modal.ShowAsync<Verification>(title: "احراز", parameters: parameters);
}
async Task CallBackVer(VerificationCodeType type)
{
await modal.HideAsync();
}
// async Task verification()
// {
// var parameters = new Dictionary<string, object>();
// parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed);
// parameters.Add("sendValue", username);
// parameters.Add("ID", 0);
// parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<VerificationCodeType>(this, CallBackVer));
// parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید");
// await modal.ShowAsync<Verification>(title: "احراز", parameters: parameters);
// }
// async Task CallBackVer(VerificationCodeType type)
// {
// await modal.HideAsync();
// }
}

View File

@@ -159,22 +159,11 @@
}
//-------------------
Loading = true;
var ID = await companyService.RegisterCompany(new Hushian.Application.Dtos.RegistrationDto()
var ID = await companyService.RegisterCompany(new Common.Dtos.Company.RegisterCompanyDto()
{
Company = new()
{
Fullname = FullName,
Info = "" ,
WebSite = WebSite
},
User = new()
{
Email = Email,
FullName = FullName,
PhoneNumber = PhoneNumber,
UserName = PhoneNumber,
PassWord = Password
}
FullName = FullName,
Mobile = PhoneNumber,
Password = Password
});
Loading = false;
if (ID > 0)

View File

@@ -2,8 +2,8 @@
@page "/"
@inject IJSRuntime JS
@using Hushian.Application.Dtos
@using HushianWebApp.Data.Models
@using Common.Dtos.Conversation
@using HushianWebApp.Models
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject ILocalStorageService localStorageService;
@@ -62,10 +62,10 @@
<div class="flex-grow-1">
<div class="d-flex justify-content-between">
<strong>@item.UserFullName</strong>
<small class="text-muted">@item.Cdate</small>
<small class="text-muted">@item.Ctime</small>
<small class="text-muted">@item.LastMsgdate</small>
<small class="text-muted">@item.LastMsgtime</small>
</div>
<div class="text-muted small text-truncate">@item.Title</div>
<div class="text-muted small text-truncate">@item.LastText</div>
</div>
@if (item.NoReadCount > 0)
{
@@ -89,10 +89,10 @@
<div class="flex-grow-1">
<div class="d-flex justify-content-between">
<strong>@item.UserFullName</strong>
<small class="text-muted">@item.Cdate</small>
<small class="text-muted">@item.Ctime</small>
<small class="text-muted">@item.LastMsgdate</small>
<small class="text-muted">@item.LastMsgtime</small>
</div>
<div class="text-muted small text-truncate">@item.Title</div>
<div class="text-muted small text-truncate">@item.LastText</div>
</div>
@if (item.NoReadCount>0)
{
@@ -115,10 +115,10 @@
<div class="flex-grow-1">
<div class="d-flex justify-content-between">
<strong>@item.UserFullName</strong>
<small class="text-muted">@item.Cdate</small>
<small class="text-muted">@item.Ctime</small>
<small class="text-muted">@item.LastMsgdate</small>
<small class="text-muted">@item.LastMsgtime</small>
</div>
<div class="text-muted small text-truncate">@item.Title</div>
<div class="text-muted small text-truncate">@item.LastText</div>
</div>
</div>
@@ -159,19 +159,19 @@
public int countInbox1 { get { return Inbox1Items.Count(); } }
public int countInbox2 { get { return Inbox2Items.Count(); } }
public List<ConversationDto> Inbox1Items { get; set; }
public List<Read_ConversationDto> Inbox1Items { get; set; }
= new() ;
public List<ConversationDto> Inbox2Items { get; set; }
public List<Read_ConversationDto> Inbox2Items { get; set; }
= new();
public List<ConversationDto> Inbox3Items { get; set; }
public List<Read_ConversationDto> Inbox3Items { get; set; }
= new();
public ConversationDto? SelectedConversation { get; set; } = null;
public List<ConversationItemDto>? SelectedConversationItems { get; set; }
public Read_ConversationDto? SelectedConversation { get; set; } = null;
public List<Read_ConversationResponseDto>? SelectedConversationItems { get; set; }
= null;
public string SelectedChatUserName { get; set; } = "مهدی ربیع نژاد";
public List<string> Roles { get; set; }
public string UserID = "";
public string Role { get; set; }
public int UserID = 0;
async Task OnclickInbox(int ID)
{
switch (ID)
@@ -203,8 +203,8 @@
if (!string.IsNullOrEmpty(MsgInput) && SelectedConversationItems!=null)
{
await conversationService.ADDConversationItemFromCompanySide(SelectedConversationItems[0].ConversationID, MsgInput);
SelectedConversationItems?.Add(new() { text = MsgInput, Type = Hushian.Enums.ConversationType.EU });
SelectedConversation.Title = MsgInput;
SelectedConversationItems?.Add(new() { text = MsgInput, Type = Common.Enums.ConversationType.EU });
SelectedConversation.LastText = MsgInput;
await Task.Yield();
await JS.InvokeVoidAsync("scrollToBottom", "B1");
MsgInput = string.Empty;
@@ -217,7 +217,7 @@
await SendMsg();
}
}
async Task onClickSelectedCon(int InboxID,ConversationDto conversationDto)
async Task onClickSelectedCon(int InboxID,Read_ConversationDto conversationDto)
{
// پر کردن SelectedCon
// مقدار دادن به SelectedChatUserName
@@ -239,11 +239,11 @@
@functions{
protected override async Task OnInitializedAsync()
{
Roles = await localStorageService.GetItem<List<string>>("Role");
Role = await localStorageService.GetItem<string>("Role");
UserID= await localStorageService.GetItem<string>("UserID");
UserID= await localStorageService.GetItem<int>("UserID");
convloading = true;
await LoadSessionB();
Inbox1Items =await conversationService.ConversationAwaitingOurResponse();
@@ -307,14 +307,14 @@
{
<p type="text" class="form-control fw-bold text-primary" style="border:none;align-self: center;" aria-describedby="basic-addon1">@SelectedChatUserName</p>
<span class="input-group-text-chat" id="basic-addon1">
@if ( SelectedConversation.status==Hushian.Enums.ConversationStatus.InProgress)
@if ( SelectedConversation.status==Common.Enums.ConversationStatus.InProgress)
{
<Button Color="ButtonColor.Danger" Size=ButtonSize.ExtraSmall Outline="true"
@onclick="async()=>
{
if(await conversationService.ConversationIsFinish(SelectedConversation.ID))
SelectedConversation.status=Hushian.Enums.ConversationStatus.Finished;
SelectedConversation.status=Common.Enums.ConversationStatus.Finished;
}">
<Icon Name="IconName.Escape" /> اتمام گفتگو
</Button>
@@ -324,14 +324,14 @@
<Icon Name="IconName.EnvelopeArrowUp" /> ارجاع به...
</Button>
}
else if (SelectedConversation.status == Hushian.Enums.ConversationStatus.Finished
&& (Roles.Contains("HushianManagerCompany") || SelectedConversation.ExperID == UserID))
else if (SelectedConversation.status == Common.Enums.ConversationStatus.Finished
&& (Role=="Company" || SelectedConversation.ExperID == UserID))
{
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true"
@onclick="async()=>{
if(await conversationService.ConversationIsStart(SelectedConversation.ID))
SelectedConversation.status=Hushian.Enums.ConversationStatus.InProgress;
SelectedConversation.status=Common.Enums.ConversationStatus.InProgress;
}"
}">
@@ -368,7 +368,7 @@
@if (SelectedConversation != null && SelectedConversation.status!=Hushian.Enums.ConversationStatus.Finished && SelectedConversationItems != null)
@if (SelectedConversation != null && SelectedConversation.status!=Common.Enums.ConversationStatus.Finished && SelectedConversationItems != null)
{
<!-- B2: Message input -->
<div class="border m-2 p-2 rounded d-flex align-items-center" id="B2">

View File

@@ -1,4 +1,4 @@
@using Hushian.Application.Dtos
@using Common.Dtos.Conversation
<div style="display: flex; "
dir="rtl" class="p-1 rounded w-100">
@@ -22,6 +22,6 @@
@code {
[Parameter] public List<ConversationDto> Conversations { get; set; }
[Parameter] public List<ConversationItemDto> SelectedConversationItems { get; set; }
[Parameter] public List<Read_ConversationDto> Conversations { get; set; }
[Parameter] public List<Read_ConversationResponseDto> SelectedConversationItems { get; set; }
}

View File

@@ -1,5 +1,5 @@
@inject ConversationService conversationService
@using Hushian.Application.Dtos
@using Common.Dtos.Group
@using HushianWebApp.Service
@if (groups.Where(w => w.Available).Count() > 0)
{
@@ -10,7 +10,7 @@
@code {
[Parameter]
public List<GroupDto> groups { get; set; }
public List<Read_GroupDto> groups { get; set; }
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
[Parameter] public int CompanyID { get; set; }
async Task onClickSelectedGroup(int ID)

View File

@@ -57,7 +57,10 @@
async Task Login()
{
visible = true;
ID= await AuthService.login(Username);
ID= await AuthService.login(new Common.Models.Auth.UserSide.AuthRequestFromUserSide()
{
Mobile=Username
});
visible = false;
}
async Task ver()

View File

@@ -1,5 +1,6 @@
@using Hushian.Application.Dtos
@using Hushian.Application.Dtos.Company
@using Common.Dtos.Company
@using Common.Dtos.Conversation
@using Common.Dtos.Group
@using HushianWebApp.Components.UserPanel
@using HushianWebApp.Service
@using HushianWebApp.Services
@@ -60,7 +61,7 @@
}
</div>
@if (IsLogin && (Conversations.Count == 0 && SelectedConversation == null) || (Conversations.Count > 0 && SelectedConversation != null && SelectedConversation.status == Hushian.Enums.ConversationStatus.InProgress))
@if (IsLogin && (Conversations.Count == 0 && SelectedConversation == null) || (Conversations.Count > 0 && SelectedConversation != null && SelectedConversation.status == Common.Enums.ConversationStatus.InProgress))
{
<div class="card-header text-white d-flex justify-content-between align-items-center">
<input type="text" class="form-control" @bind-value="InputMessage" placeholder="پیام خود را بنویسید..." style="margin-left:10px" />
@@ -91,13 +92,13 @@
[Parameter] public int? ConversationID { get; set; }
#endregion
#region Fild
public ConversationDto? SelectedConversation { get; set; } = null;
public List<ConversationDto> Conversations { get; set; } = new();
public List<ConversationItemDto>? SelectedConversationItems { get; set; } = null;
public Read_ConversationDto? SelectedConversation { get; set; } = null;
public List<Read_ConversationDto> Conversations { get; set; } = new();
public List<Read_ConversationResponseDto>? SelectedConversationItems { get; set; } = null;
public RenderFragment GCContent { get; set; }
public RenderFragment ConversationsContent { get; set; }
List<GroupDto> groups = new List<GroupDto>();
public CompanyDto company { get; set; } = new();
List<Read_GroupDto> groups = new List<Read_GroupDto>();
public ReadANDUpdate_CompanyDto company { get; set; } = new();
int CountQueueCompany = 0;
public string CompanyName { get; set; } = "هوشیان";
public bool IsLogin { get; set; } = false;
@@ -167,7 +168,7 @@
}
else
{
CompanyName = _company.Fullname;
CompanyName = _company.FullName;
company = _company;
var _groups = await groupService.GetGroupsCompany(CompanyID);
@@ -220,15 +221,15 @@
Sending = true;
if (SelectedConversation != null)
{
var item = new ADDConversationItemDto()
var item = new ADD_ConversationResponseDto()
{
ConversationID = SelectedConversation.ID,
text = InputMessage
Text = InputMessage
};
}
else
{
var Item = new ADDConversationDto()
var Item = new ADD_ConversationDto()
{
CompanyID = CompanyID,
GroupID = SelectedGroup,

View File

@@ -1,7 +1,7 @@
@page "/GroupManagement"
<Modal @ref="modal" />
<ConfirmDialog @ref="dialog" />
@using Hushian.Application.Dtos
@using Common.Dtos.Group
@using HushianWebApp.Components
@using HushianWebApp.Service
@using HushianWebApp.Services
@@ -15,7 +15,7 @@
گروه جدید
</Button>
<Grid @ref="grid" TItem="GroupDto"
<Grid @ref="grid" TItem="Read_GroupDto"
AllowSorting="true"
Class="table table-hover"
DataProvider="DataProvider"
@@ -26,7 +26,7 @@ OnRowDoubleClick="OnRowClick"
AllowRowClick=true>
<GridColumns>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="تصویر گروه" >
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="تصویر گروه">
@if (context.img?.Length!=0)
{
<Image Class="rounded-circle mx-auto d-block" src="@GetImageSource(context.img)" height="25" width="25" alt="Uploaded Image" />
@@ -36,23 +36,23 @@ AllowRowClick=true>
<Icon Name="IconName.People" Size="IconSize.x5" />
}
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="شناسه گروه" SortKeySelector="item => item.ID">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="شناسه گروه" SortKeySelector="item => item.ID">
@context.ID
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="نام گروه" SortKeySelector="item => item.Name">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="نام گروه" SortKeySelector="item => item.Name">
@context.Name
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="توضیحات" >
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="توضیحات">
@context.Info
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="وضعیت">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="وضعیت">
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="عملیات">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_GroupDto" HeaderText="عملیات">
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteGroup(context.ID,context.Name)"> حذف </Button>
<Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.ID,context.Name)"> کاربران </Button>
@@ -65,11 +65,11 @@ AllowRowClick=true>
private ConfirmDialog dialog = default!;
Dictionary<string, object> parameters = new Dictionary<string, object>();
Grid<GroupDto> grid = default!;
Grid<Read_GroupDto> grid = default!;
private Modal modal = default!;
string title = "گروه جدید";
public List<GroupDto> list = new();
private async Task<GridDataProviderResult<GroupDto>> DataProvider(GridDataProviderRequest<GroupDto> request)
public List<Read_GroupDto> list = new();
private async Task<GridDataProviderResult<Read_GroupDto>> DataProvider(GridDataProviderRequest<Read_GroupDto> request)
{
if(list.Count <= 0)
list = await groupService.GetGroupsCompany();
@@ -86,7 +86,7 @@ AllowRowClick=true>
navigationManager.NavigateTo("/NotFound");
await base.OnInitializedAsync();
}
private async Task OnRowClick(GridRowEventArgs<GroupDto> args)
private async Task OnRowClick(GridRowEventArgs<Read_GroupDto> args)
{
Dictionary<string, object> eparameters = new Dictionary<string, object>();
eparameters.Add("model", args.Item);
@@ -97,7 +97,7 @@ AllowRowClick=true>
}
private async Task SwitchChanged(GroupDto model, bool value)
private async Task SwitchChanged(Read_GroupDto model, bool value)
{
if (model.Available != value)
{

View File

@@ -1,5 +1,5 @@
@page "/Settings"
@using Hushian.Application.Dtos.Company
@using Common.Dtos.Company
@using HushianWebApp.Components
@using HushianWebApp.Service
@using HushianWebApp.Services
@@ -71,7 +71,10 @@
</div>
<div class="col-md-12" style="margin-top:15px">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Fullname" type="text" placeholder="نام کامل" />
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.FullName" type="text" placeholder="نام شرکت" />
</div>
<div class="col-md-12" style="margin-top:15px">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.FullNameManager" type="text" placeholder="نام مدیر" />
</div>
<div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Email" type="text" placeholder="پست الکترونیک" />
@@ -79,22 +82,17 @@
<div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.WebSite" type="text" placeholder="وب سایت" />
</div>
<div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Phone" type="text" placeholder="تلفن" />
</div>
<div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Info" type="text" placeholder="توضیحات" />
</div>
<div class="col-md-12 d-flex align-items-center mb-2">
<InputFile type="file" OnChange="OnFileChange" accept=".png" />
@if (dto.img != null && dto.img.Length > 0)
@if (dto.logo != null && dto.logo.Length > 0)
{
<Image src="@GetImageSource()" class="rounded mx-2" height="25" width="25" alt="Uploaded Image" />
}
</div>
<div class="d-grid gap-2">
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning"
@onclick="updateItem">
@onclick="updateItem">
ویرایش
</Button>
</div>
@@ -127,18 +125,20 @@
</div>
@code {
[Inject] protected ToastService ToastService { get; set; } = default!;
[Inject] protected ToastService ToastService { get; set; } = default!;
bool ALLOWcompanyinfo = true;
bool ALLOWcompanyinfo = true;
public bool loading { get; set; } = false;
public CompanyDto dto { get; set; }
public ReadANDUpdate_CompanyDto dto { get; set; }
= new();
int CompanyID = 0;
protected override async Task OnInitializedAsync()
{
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a => a == "HushianManagerCompany"))
if (await localStorageService.GetItem<string>("Role") != "Company")
navigationManager.NavigateTo("/NotFound");
CompanyID= await localStorageService.GetItem<int>("C/CompanyId");
dto=await companyService.GetCompany();
dto = await companyService.GetCompany(CompanyID);
await base.OnInitializedAsync();
}
private async Task OnFileChange(InputFileChangeEventArgs e)
@@ -147,14 +147,14 @@
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
dto.img = memoryStream.ToArray();
dto.logo = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (dto.img != null)
if (dto.logo != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.img)}";
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.logo)}";
}
return string.Empty;
}

View File

@@ -1,7 +1,6 @@
@page "/UserManagement"
<ConfirmDialog @ref="dialog" />
@using Common.Dtos.User
@using Hushian.Application.Dtos
@using Common.Dtos.Exper
@using HushianWebApp.Components
@using HushianWebApp.Service
@using HushianWebApp.Services
@@ -17,7 +16,7 @@
کارشناس جدید
</Button>
<Grid @ref="grid" TItem="HushianUserDto"
<Grid @ref="grid" TItem="Read_ExperDto"
AllowSorting="true"
Class="table table-hover"
DataProvider="DataProvider"
@@ -28,39 +27,23 @@ OnRowDoubleClick="OnRowClick"
AllowRowClick=true>
<GridColumns>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="تصویر کاربر" >
@if (context.img?.Length != 0)
{
<Image Class="rounded-circle mx-auto d-block" src="@GetImageSource(context.img)" height="25" width="25" alt="Uploaded Image" />
}
else
{
<Icon Name="IconName.Person" Size="IconSize.x5" />
}
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="نام کاریری" SortKeySelector="item => item.UserName">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="نام کاریری" SortKeySelector="item => item.UserName">
@context.UserName
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="نام کامل" SortKeySelector="item => item.FullName">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="نام کامل" SortKeySelector="item => item.FullName">
@context.FullName
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="پست اکترونیک" SortKeySelector="item => item.Email">
@context.Email
</GridColumn>
@* <GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="موبابل" SortKeySelector="item => item.PhoneNumber">
@context.PhoneNumber
</GridColumn> *@
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="وضعیت">
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="وضعیت">
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
</GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="عملیات">
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteExper(context.UserID,context.FullName)"> حذف </Button>
<Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.UserID,context.FullName)"> گروه ها </Button>
<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>
</GridColumn>
</GridColumns>
@@ -71,35 +54,32 @@ AllowRowClick=true>
private ConfirmDialog dialog = default!;
Dictionary<string, object> parameters = new Dictionary<string, object>();
Grid<HushianUserDto> grid = default!;
Grid<Read_ExperDto> grid = default!;
private Modal modal = default!;
string title = "کارشناس جدید";
protected override async Task OnInitializedAsync()
{
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a =>a== "HushianManagerCompany") )
if (await localStorageService.GetItem<string>("Role")!= "Company" )
navigationManager.NavigateTo("/NotFound");
await base.OnInitializedAsync();
}
private async Task<GridDataProviderResult<HushianUserDto>> DataProvider(GridDataProviderRequest<HushianUserDto> request)
private async Task<GridDataProviderResult<Read_ExperDto>> DataProvider(GridDataProviderRequest<Read_ExperDto> request)
{
var employees = await userService.GetExpersCompany(0, request.PageNumber, request.PageSize);
return await Task.FromResult(request.ApplyTo(employees != null ? employees.list : new()));
return await Task.FromResult(request.ApplyTo(employees != null ? employees : new()));
}
async Task CallBack()
{
await modal.HideAsync();
await grid.RefreshDataAsync();
}
private async Task OnRowClick(GridRowEventArgs<HushianUserDto> args)
private async Task OnRowClick(GridRowEventArgs<Read_ExperDto> args)
{
var editmodel = new EditUserFromUserDto()
var editmodel = new Update_ExperDto()
{
Email = args.Item.Email,
FullName = args.Item.FullName,
UserName = args.Item.UserName,
img = args.Item.img
FullName = args.Item.FullName
};
Dictionary<string, object> eparameters = new Dictionary<string, object>();
eparameters.Add("model", editmodel);
@@ -108,17 +88,17 @@ AllowRowClick=true>
await modal.ShowAsync<UpdateExperComponent>($"ویرایش کارشناس {args.Item.FullName}", parameters: eparameters);
}
private async Task SwitchChanged(HushianUserDto model,bool value)
private async Task SwitchChanged(Read_ExperDto model, bool value)
{
if (model.Available != value)
{
if (await userService.ChangeAvailableExperFromManager(model.UserID, value))
if (await userService.ChangeAvailableExperFromManager(model.ID, value))
model.Available = value;
}
}
private async Task DeleteExper(string ExperID,string name)
private async Task DeleteExper(int ExperID,string name)
{
var confirmation = await dialog.ShowAsync(
title: $"مطمئنی می‌خوای {name} حذف کنی؟",
@@ -144,7 +124,7 @@ AllowRowClick=true>
}
return string.Empty;
}
async Task showGroupsComponent(string ExperID, string name)
async Task showGroupsComponent(int ExperID, string name)
{
Dictionary<string, object> eparameters = new Dictionary<string, object>();
eparameters.Add("ExperID", ExperID);

View File

@@ -24,12 +24,12 @@ namespace HushianWebApp.Service
var response = await _baseController.Put($"{BaseRoute}UpdateGroup", Group);
return response.IsSuccessStatusCode;
}
public async Task<bool> JoinExperToGroup(int GroupID, string ExperID)
public async Task<bool> JoinExperToGroup(int GroupID, int ExperID)
{
var response = await _baseController.Put($"{BaseRoute}JoinExperToGroup/{GroupID}/{ExperID}");
return response.IsSuccessStatusCode;
}
public async Task<bool> UnJoinExperToGroup(int GroupID, string ExperID)
public async Task<bool> UnJoinExperToGroup(int GroupID, int ExperID)
{
var response = await _baseController.Put($"{BaseRoute}UnJoinExperToGroup/{GroupID}/{ExperID}");
return response.IsSuccessStatusCode;
@@ -57,7 +57,7 @@ namespace HushianWebApp.Service
}
return null;
}
public async Task<List<Read_GroupDto>?> GetGroupsFromExperID(string ExperID)
public async Task<List<Read_GroupDto>?> GetGroupsFromExperID(int ExperID)
{
var response = await _baseController.Get($"{BaseRoute}GetGroupsFromExperID?ExperID={ExperID}");
if (response.IsSuccessStatusCode)

View File

@@ -71,13 +71,13 @@ namespace HushianWebApp.Service
}
public async Task<bool> ChangeAvailableExperFromManager(string ExperID,bool Available)
public async Task<bool> ChangeAvailableExperFromManager(int ExperID,bool Available)
{
var response = await _baseController.Put($"{BaseRoute}ChangeAvailableExperFromManager/{ExperID}?Available={Available}");
return response.IsSuccessStatusCode;
}
public async Task<bool>DeleteExperFromManager(string ExperID)
public async Task<bool>DeleteExperFromManager(int ExperID)
{
var response = await _baseController.Delete($"{BaseRoute}DeleteExperFromManager/{ExperID}");
return response.IsSuccessStatusCode;