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,5 +1,5 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Hushian.Application.Validation namespace Common.Validation
{ {
public static class FixedValidation public static class FixedValidation
{ {

View File

@@ -1,12 +1,11 @@
using Common.Models.Auth; using Common.Models.Auth;
using Common.Models.Auth.CompanySide; using Common.Models.Auth.CompanySide;
using Common.Models.Auth.UserSide; using Common.Models.Auth.UserSide;
using Common.Validation;
using Hushian.Application.Constants; using Hushian.Application.Constants;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
using Hushian.Application.Validation;
using Hushian.Domain.Entites; using Hushian.Domain.Entites;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;

View File

@@ -1,18 +1,11 @@
using AutoMapper; using AutoMapper;
using Common.Dtos; using Common.Dtos;
using Common.Dtos.Company; using Common.Dtos.Company;
using Common.Dtos.Exper; using Common.Validation;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
using Hushian.Application.Validation;
using Hushian.Domain.Entites; using Hushian.Domain.Entites;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Services namespace Hushian.Application.Services
{ {

View File

@@ -1,5 +1,4 @@
using AutoMapper; using Common.Dtos.Conversation;
using Common.Dtos.Conversation;
using Common.Enums; using Common.Enums;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
@@ -7,12 +6,6 @@ using Hushian.Domain.Entites;
using Hushian.WebApi; using Hushian.WebApi;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Services namespace Hushian.Application.Services
{ {
@@ -149,7 +142,7 @@ namespace Hushian.Application.Services
UserFullName = s.User.FullName UserFullName = s.User.FullName
}).ToListAsync(); }).ToListAsync();
public async Task<List<Read_ConversationResponseDto>> GetConversationItems(int ConversationID, int? ExperID) public async Task<List<Read_ConversationResponseDto>> GetConversationItems(int ConversationID)
{ {
return await _ConversationResponseRepository.Get() return await _ConversationResponseRepository.Get()
.Include(inc=>inc.Exper) .Include(inc=>inc.Exper)

View File

@@ -3,15 +3,9 @@ using Common.Dtos;
using Common.Dtos.Exper; using Common.Dtos.Exper;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
using Hushian.Application.Validation; using Common.Validation;
using Hushian.Domain.Entites; using Hushian.Domain.Entites;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Services namespace Hushian.Application.Services
{ {

View File

@@ -3,14 +3,9 @@ using Common.Dtos.Exper;
using Common.Dtos.Group; using Common.Dtos.Group;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
using Hushian.Application.Validation; using Common.Validation;
using Hushian.Domain.Entites; using Hushian.Domain.Entites;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Services namespace Hushian.Application.Services
{ {

View File

@@ -4,17 +4,13 @@ using Common.Enums;
using Common.Models.Auth; using Common.Models.Auth;
using Hushian.Application.Contracts.Persistence; using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models; using Hushian.Application.Models;
using Hushian.Application.Validation; using Common.Validation;
using Hushian.Domain.Entites; using Hushian.Domain.Entites;
using Identity.Models; using Identity.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Hushian.Application.Services namespace Hushian.Application.Services
{ {

View File

@@ -1,7 +1,7 @@
@using Common.Dtos.User @using Common.Dtos.Exper
@using Hushian.Application.Dtos
@using HushianWebApp.Service @using HushianWebApp.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@using Common.Validation
@inject UserService userService; @inject UserService userService;
<div class="row" style="height: fit-content; padding: 1rem;"> <div class="row" style="height: fit-content; padding: 1rem;">
@@ -13,21 +13,11 @@
</div> </div>
<div class="col-md-12"> <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>
<div class="col-md-12"> <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="پست الکترونیک" /> <input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@RePassword" type="password" 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> </div>
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button> <Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button>
@@ -36,18 +26,43 @@
@code { @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; } [Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false; 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() 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; loading = true;
if (await userService.AddExper(model)) if (await userService.AddExper(model))
{ {
@@ -60,23 +75,23 @@
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
model = new(); model = new();
await base.OnParametersSetAsync(); 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;
} }
// 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 @using HushianWebApp.Service
@inject GroupService groupService; @inject GroupService groupService;
<div class="row" style="height: fit-content; padding: 1rem;"> <div class="row" style="height: fit-content; padding: 1rem;">
@@ -27,7 +27,7 @@
</div> </div>
@code { @code {
[Parameter] public ADDGroupDto model { get; set; } = new(); [Parameter] public ADD_GroupDto model { get; set; } = new();
[Parameter] public EventCallback OnMultipleOfThree { get; set; } [Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false; public bool loading { get; set; } = false;
} }

View File

@@ -1,30 +1,30 @@
@using Hushian.Application.Dtos @using Common.Dtos.Conversation
@inject IJSRuntime JSRuntime @inject IJSRuntime JSRuntime
<div class="chat-container p-3"> <div class="chat-container p-3">
@foreach (var msg in Messages) @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; target = true;
<div id="target" style="text-align: center;"> <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> <p>ـــــــــــــــــــــــــ</p>
} }
</div> </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" <div class="d-flex mb-2 @(msg.Type==Common.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")">
: msg.Type==Hushian.Enums.ConversationType.UE && msg.ExperID=="bot" ? "chat-ai" : "chat-other")" data-id="@msg.ID"> <div class="chat-bubble @(msg.Type==Common.Enums.ConversationType.UE ? "chat-mine"
: "chat-other")" data-id="@msg.ID">
@msg.text @msg.text
</div> </div>
@if (msg.Type == Hushian.Enums.ConversationType.EU) @if (msg.Type == Common.Enums.ConversationType.EU)
{ {
if (msg.IsRead) if (msg.IsRead)
{ {
@@ -75,7 +75,7 @@
@code { @code {
bool target = false; bool target = false;
[Parameter] [Parameter]
public List<ConversationItemDto> Messages { get; set; } = new(); public List<Read_ConversationResponseDto> Messages { get; set; } = new();
[Parameter] public EventCallback<int> EventCallIsRead { get; set; } [Parameter] public EventCallback<int> EventCallIsRead { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
@@ -91,7 +91,7 @@
public async Task MarkAsRead(int id) public async Task MarkAsRead(int id)
{ {
var msg = Messages.FirstOrDefault(m => m.ID == 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; msg.IsRead = true;
await EventCallIsRead.InvokeAsync(id); 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.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@inject UserService userService; @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;"> <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> <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> <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> <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="تکرار رمز عبور جدید" /> <input dir="ltr" style="text-align:center" @bind="RePassword" type="password" class="form-control" placeholder="تکرار رمز عبور جدید" />
@@ -31,25 +32,33 @@
@code { @code {
[Inject] protected ToastService ToastService { get; set; } = default!; [Inject] protected ToastService ToastService { get; set; } = default!;
public bool SpinnerVisible { get; set; } public bool SpinnerVisible { get; set; }
public ChangePasswordFromUserDto dto { get; set; } = new(); public ChangePasswordDto dto { get; set; } = new();
public string RePassword { get; set; } = ""; public string RePassword { get; set; } = "";
public string Username { get; set; } = ""; public string Username { get; set; } = "";
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
Username = await localStorageService.GetItem<string>("Username"); // Username = await localStorageService.GetItem<string>("Username");
dto = new() { UserName = Username }; // dto = new() { UserName = Username };
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
} }
async Task Click() async Task Click()
{ {
if (string.IsNullOrEmpty(dto.OldPassword) || string.IsNullOrEmpty(dto.NewPassword)) if (string.IsNullOrEmpty(dto.OldPassWord) || string.IsNullOrEmpty(dto.NewPassWord))
return; return;
if (dto.NewPassword != RePassword) if (dto.NewPassWord != RePassword)
{ {
ToastService.Notify(new ToastMessage(ToastType.Danger, "کلمه عبور با تکرار متفاوت است")); ToastService.Notify(new ToastMessage(ToastType.Danger, "کلمه عبور با تکرار متفاوت است"));
return; return;
} }
List<string> errors = new();
if (!dto.NewPassWord.CheckLawPassword(ref errors))
{
ToastService.Notify(new(ToastType.Danger, errors.First()));
return ;
}
SpinnerVisible = true; SpinnerVisible = true;
var result = await userService.ChangePasswordYourself(dto); var result = await userService.ChangePasswordYourself(dto);
if (result) if (result)

View File

@@ -1,4 +1,5 @@
@using Common.Dtos.User @using Common.Dtos.Exper
@using Common.Validation
@using HushianWebApp.Service @using HushianWebApp.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@inject UserService userService; @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="نام کامل" /> <input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام کامل" />
</div> </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> <Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
@if (isAuthorizedCompanyUser)
{
<Button Loading=loading LoadingText="در حال آزادسازی..." Color="ButtonColor.Danger" @onclick="FreeExper"> آزادسازی کارشناس </Button>
}
</div> </div>
@code { @code {
bool isAuthorizedCompanyUser = false; bool isAuthorizedCompanyUser = false;
[Parameter] public EventCallback<EditUserFromUserDto> OnMultipleOfThree { get; set; } [Parameter] public EventCallback<Update_ExperDto> OnMultipleOfThree { get; set; }
public List<string> Roles { get; set; } = new(); public string Role { get; set; }
public bool loading { get; set; } = false; public bool loading { get; set; } = false;
[Inject] protected ToastService ToastService { get; set; } = default!; [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() protected override async Task OnInitializedAsync()
{ {
var user=await userService.GetCurrentUser(); var user=await userService.GetCurrentUser();
if (user!=null) if (user!=null)
{ {
model.UserName=user.UserName;
model.img = user.img;
model.FullName = user.FullName; model.FullName = user.FullName;
model.Email = user.Email;
Roles = await localStorageService.GetItem<List<string>>("Role"); Role = await localStorageService.GetItem<string>("Role");
isAuthorizedCompanyUser = Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany(); isAuthorizedCompanyUser = Role=="Exper" && await userService.CheckAvailableExperInCompany();
} }
else else
{ {
@@ -59,30 +41,16 @@
} }
await base.OnInitializedAsync(); 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() async Task NewItem()
{ {
if (!string.IsNullOrEmpty(model.FullName)) if (!string.IsNullOrEmpty(model.FullName))
{ {
if (!model.FullName.IsOnlyPersianLetters())
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir"; {
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return;
}
loading = true; loading = true;
if (await userService.EditUserYourself(model)) if (await userService.EditUserYourself(model))
{ {
@@ -92,15 +60,5 @@
loading = false; 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 @using HushianWebApp.Service
@inject GroupService groupService; @inject GroupService groupService;
@inject UserService userService; @inject UserService userService;
@@ -7,14 +7,14 @@
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12" style="margin-bottom:15px"> <div class="col-md-12 col-sm-12" style="margin-bottom:15px">
<AutoComplete @bind-Value="ExperName" <AutoComplete @bind-Value="ExperName"
TItem="HushianUserDto" TItem="Read_ExperDto"
DataProvider="DataProvider" DataProvider="DataProvider"
PropertyName="FullName" PropertyName="FullName"
Placeholder="جستجو در کاربران..." Placeholder="جستجو در کاربران..."
OnChanged="(HushianUserDto exper) => OnAutoCompleteChanged(exper)" /> OnChanged="(Read_ExperDto exper) => OnAutoCompleteChanged(exper)" />
</div> </div>
</div> </div>
<SortableList TItem="HushianUserDto" <SortableList TItem="Read_ExperDto"
Data="Expers" Data="Expers"
Context="item" Context="item"
AllowSorting="false"> AllowSorting="false">
@@ -37,9 +37,9 @@
private bool Spinnervisible = false; private bool Spinnervisible = false;
[Parameter] public int GroupID { get; set; } [Parameter] public int GroupID { get; set; }
public List<HushianUserDto> Expers { get; set; } public List<Read_ExperDto> Expers { get; set; }
= new(); = new();
public List<HushianUserDto> CoExpers { get; set; } public List<Read_ExperDto> CoExpers { get; set; }
= new(); = new();
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
@@ -50,25 +50,25 @@
} }
} }
@functions { @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; CoExpers = await userService.GetExpersCompany(0, 0, 0);
return await Task.FromResult(new AutoCompleteDataProviderResult<HushianUserDto> { Data = CoExpers.Where(w => w.FullName.Contains(request.Filter.Value)), TotalCount = CoExpers.Count() }); 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; Spinnervisible = true;
if (exper != null if (exper != null
&& !Expers.Any(a => a.UserID == exper.UserID) && !Expers.Any(a => a.ID == exper.ID)
&& await groupService.JoinExperToGroup(GroupID, exper.UserID) ) && await groupService.JoinExperToGroup(GroupID, exper.ID) )
Expers.Add(exper); Expers.Add(exper);
Spinnervisible = false; Spinnervisible = false;
} }
async Task UnJoin(HushianUserDto exper) async Task UnJoin(Read_ExperDto exper)
{ {
Spinnervisible = true; Spinnervisible = true;
if (exper != null && await groupService.UnJoinExperToGroup(GroupID, exper.UserID)) if (exper != null && await groupService.UnJoinExperToGroup(GroupID, exper.ID))
Expers.Remove(exper); Expers.Remove(exper);
Spinnervisible = false; 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.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@using Common.Validation
@inject UserService userService; @inject UserService userService;
<div class="row" style="height: fit-content; padding: 1rem;"> <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="نام و نام خانوادگی" /> <input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام و نام خانوادگی" />
</div> </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> <Button Loading=loading LoadingText="در حال ویرایش اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
@@ -32,7 +20,9 @@
@code { @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; } [Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false; public bool loading { get; set; } = false;
} }
@@ -41,10 +31,13 @@
{ {
if (!string.IsNullOrEmpty(model.FullName)) 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; loading = true;
if (await userService.ExperEditingFromManager(model)) if (await userService.ExperEditingFromManager(ExperID,model))
{ {
loading = false; loading = false;
await OnMultipleOfThree.InvokeAsync(); 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 @using HushianWebApp.Service
@inject GroupService groupService; @inject GroupService groupService;
<div class="row" style="height: fit-content; padding: 1rem;"> <div class="row" style="height: fit-content; padding: 1rem;">
@@ -28,7 +28,7 @@
</div> </div>
@code { @code {
[Parameter] public GroupDto model { get; set; } [Parameter] public Update_GroupDto model { get; set; }
[Parameter] public EventCallback OnMultipleOfThree { get; set; } [Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false; public bool loading { get; set; } = false;
} }

View File

@@ -1,4 +1,5 @@
@using Hushian.Application.Dtos 
@using Common.Dtos.Group
@using HushianWebApp.Service @using HushianWebApp.Service
@inject GroupService groupService; @inject GroupService groupService;
@@ -7,14 +8,14 @@
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12" style="margin-bottom:15px"> <div class="col-md-12 col-sm-12" style="margin-bottom:15px">
<AutoComplete @bind-Value="GroupName" <AutoComplete @bind-Value="GroupName"
TItem="GroupDto" TItem="Read_GroupDto"
DataProvider="DataProvider" DataProvider="DataProvider"
PropertyName="Name" PropertyName="Name"
Placeholder="جستجو در گروه ها..." Placeholder="جستجو در گروه ها..."
OnChanged="(GroupDto group) => OnAutoCompleteChanged(group)" /> OnChanged="(Read_GroupDto group) => OnAutoCompleteChanged(group)" />
</div> </div>
</div> </div>
<SortableList TItem="GroupDto" <SortableList TItem="Read_GroupDto"
Data="Groups" Data="Groups"
Context="item" Context="item"
AllowSorting="false"> AllowSorting="false">
@@ -35,10 +36,10 @@
private string? GroupName; private string? GroupName;
private bool Spinnervisible = false; private bool Spinnervisible = false;
[Parameter] public string ExperID { get; set; } [Parameter] public int ExperID { get; set; }
public List<GroupDto> Groups { get; set; } public List<Read_GroupDto> Groups { get; set; }
= new(); = new();
public List<GroupDto> CoGroups { get; set; } public List<Read_GroupDto> CoGroups { get; set; }
= new(); = new();
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
@@ -49,13 +50,13 @@
} }
} }
@functions { @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(); 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; Spinnervisible = true;
if (group != null if (group != null
@@ -64,7 +65,7 @@
Groups.Add(group); Groups.Add(group);
Spinnervisible = false; Spinnervisible = false;
} }
async Task UnJoin(GroupDto group) async Task UnJoin(Read_GroupDto group)
{ {
Spinnervisible = true; Spinnervisible = true;
if (group != null && await groupService.UnJoinExperToGroup(group.ID, ExperID)) 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> <small>پیام های اخیر شما ...</small>
<div class="row"> <div class="row">
@foreach (var item in Conversations) @foreach (var item in Conversations)
@@ -6,13 +7,13 @@
<div class="col-sm-3"> <div class="col-sm-3">
<Card> <Card>
<CardBody> <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> <Button Color="ButtonColor.Primary" @onclick="async()=>await OnMultipleOfThree.InvokeAsync(item.ID)" Type="ButtonType.Link">Go somewhere</Button>
</CardBody> </CardBody>
<ul class="list-group list-group-flush"> <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> </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" <Badge Color="BadgeColor.Danger"
Position="Position.Absolute" Position="Position.Absolute"
@@ -31,7 +32,7 @@
@code { @code {
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; } [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) string GetTitleCon(string str)
{ {
if (str.Length > 15) return str.Substring(0, 15) + "..."; 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 Common.Enums
@using HushianWebApp.Service @using HushianWebApp.Service
@inject VerificationService verificationService; @inject VerificationService verificationService;

View File

@@ -1,5 +1,5 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
@using Common.Dtos.User @using Common.Dtos.Exper
@using HushianWebApp.Components @using HushianWebApp.Components
@using HushianWebApp.Pages @using HushianWebApp.Pages
@using HushianWebApp.Pages.Manage @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(); string route = NavigationManager.Uri.Replace(NavigationManager.BaseUri, "").ToLower();
if (route.Length > 0) if (route.Length > 0)
@@ -136,17 +136,16 @@
private async Task EditCurrentUser() private async Task EditCurrentUser()
{ {
var parameters = new Dictionary<string, object>(); 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); await modal.ShowAsync<EditUserYourselfComponent>(title: $"ویرایش کاربر {Username}", parameters: parameters);
} }
async Task CallBack(EditUserFromUserDto edit) async Task CallBack(Update_ExperDto edit)
{ {
await modal.HideAsync(); await modal.HideAsync();
img = edit.img; // await localStorageService.RemoveItem("img");
await localStorageService.RemoveItem("img"); // await localStorageService.SetItem("img", img);
await localStorageService.SetItem("img", img);
Fullname = edit.FullName; Fullname = edit.FullName;
await localStorageService.RemoveItem("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" @page "/Login"
@using Common.Enums @using Common.Enums
@using Common.Models.Identity @using Common.Models.Auth.CompanySide
@using HushianWebApp.Components @using HushianWebApp.Components
@using HushianWebApp.Service @using HushianWebApp.Service
@layout BeforeLayout @layout BeforeLayout
@@ -11,7 +11,7 @@
<ConfirmDialog @ref="dialog" /> <ConfirmDialog @ref="dialog" />
<div class="header-form"> <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>
<span>به هوشیان</span> <span>به هوشیان</span>
@@ -59,7 +59,7 @@
</div> </div>
<div class=" space-y-5 flex flex-col items-center"> <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 class="btn btn-outline w-full mb-4 lg:mb-0" href="Register">
ثبت نام ثبت نام
</NavLink> </NavLink>
</div> </div>
@@ -77,27 +77,32 @@
@functions { @functions {
async Task onClick() async Task onClick()
{ {
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(Password)) return; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(Password)) return;
Loading = true; Loading = true;
var msg = await auth.login(new AuthRequest(username, Password)); var msg = await auth.login(new AuthRequestFromCompanySide()
if (msg == "PhoneNumberNotConfirmed")
{
var confirmation = await dialog.ShowAsync(
title: "احراز کاربری",
message1: "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید",
message2: "انجام بدیم؟");
if (!confirmation)
{ {
Loading = false; Username = username,
return; Password = Password
} });
await verification(); // if (msg == "PhoneNumberNotConfirmed")
} // {
else if (msg == "ok") // var confirmation = await dialog.ShowAsync(
// title: "احراز کاربری",
// message1: "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید",
// message2: "انجام بدیم؟");
// if (!confirmation)
// {
// Loading = false;
// return;
// }
// await verification();
// }
// else
if (msg == "ok")
{ {
navigationManager.NavigateTo("/"); navigationManager.NavigateTo("/");
} }
@@ -106,19 +111,19 @@
Loading = false; Loading = false;
} }
async Task verification() // async Task verification()
{ // {
var parameters = new Dictionary<string, object>(); // var parameters = new Dictionary<string, object>();
parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed); // parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed);
parameters.Add("sendValue", username); // parameters.Add("sendValue", username);
parameters.Add("ID", 0); // parameters.Add("ID", 0);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<VerificationCodeType>(this, CallBackVer)); // parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<VerificationCodeType>(this, CallBackVer));
parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید"); // parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید");
await modal.ShowAsync<Verification>(title: "احراز", parameters: parameters); // await modal.ShowAsync<Verification>(title: "احراز", parameters: parameters);
} // }
async Task CallBackVer(VerificationCodeType type) // async Task CallBackVer(VerificationCodeType type)
{ // {
await modal.HideAsync(); // await modal.HideAsync();
} // }
} }

View File

@@ -159,22 +159,11 @@
} }
//------------------- //-------------------
Loading = true; 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,
{ Mobile = PhoneNumber,
Fullname = FullName, Password = Password
Info = "" ,
WebSite = WebSite
},
User = new()
{
Email = Email,
FullName = FullName,
PhoneNumber = PhoneNumber,
UserName = PhoneNumber,
PassWord = Password
}
}); });
Loading = false; Loading = false;
if (ID > 0) if (ID > 0)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
@page "/Settings" @page "/Settings"
@using Hushian.Application.Dtos.Company @using Common.Dtos.Company
@using HushianWebApp.Components @using HushianWebApp.Components
@using HushianWebApp.Service @using HushianWebApp.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@@ -71,7 +71,10 @@
</div> </div>
<div class="col-md-12" style="margin-top:15px"> <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>
<div class="col-md-12"> <div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Email" type="text" placeholder="پست الکترونیک" /> <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"> <div class="col-md-12">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.WebSite" type="text" placeholder="وب سایت" /> <input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.WebSite" type="text" placeholder="وب سایت" />
</div> </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"> <div class="col-md-12 d-flex align-items-center mb-2">
<InputFile type="file" OnChange="OnFileChange" accept=".png" /> <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" /> <Image src="@GetImageSource()" class="rounded mx-2" height="25" width="25" alt="Uploaded Image" />
} }
</div> </div>
<div class="d-grid gap-2"> <div class="d-grid gap-2">
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" <Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning"
@onclick="updateItem"> @onclick="updateItem">
ویرایش ویرایش
</Button> </Button>
</div> </div>
@@ -127,18 +125,20 @@
</div> </div>
@code { @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 bool loading { get; set; } = false;
public CompanyDto dto { get; set; } public ReadANDUpdate_CompanyDto dto { get; set; }
= new(); = new();
int CompanyID = 0;
protected override async Task OnInitializedAsync() 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"); navigationManager.NavigateTo("/NotFound");
CompanyID= await localStorageService.GetItem<int>("C/CompanyId");
dto=await companyService.GetCompany(); dto = await companyService.GetCompany(CompanyID);
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
private async Task OnFileChange(InputFileChangeEventArgs e) private async Task OnFileChange(InputFileChangeEventArgs e)
@@ -147,14 +147,14 @@
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
{ {
await file.OpenReadStream().CopyToAsync(memoryStream); await file.OpenReadStream().CopyToAsync(memoryStream);
dto.img = memoryStream.ToArray(); dto.logo = memoryStream.ToArray();
} }
} }
private string GetImageSource() 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; return string.Empty;
} }

View File

@@ -1,7 +1,6 @@
@page "/UserManagement" @page "/UserManagement"
<ConfirmDialog @ref="dialog" /> <ConfirmDialog @ref="dialog" />
@using Common.Dtos.User @using Common.Dtos.Exper
@using Hushian.Application.Dtos
@using HushianWebApp.Components @using HushianWebApp.Components
@using HushianWebApp.Service @using HushianWebApp.Service
@using HushianWebApp.Services @using HushianWebApp.Services
@@ -17,7 +16,7 @@
کارشناس جدید کارشناس جدید
</Button> </Button>
<Grid @ref="grid" TItem="HushianUserDto" <Grid @ref="grid" TItem="Read_ExperDto"
AllowSorting="true" AllowSorting="true"
Class="table table-hover" Class="table table-hover"
DataProvider="DataProvider" DataProvider="DataProvider"
@@ -28,39 +27,23 @@ OnRowDoubleClick="OnRowClick"
AllowRowClick=true> AllowRowClick=true>
<GridColumns> <GridColumns>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="تصویر کاربر" > <GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="نام کاریری" SortKeySelector="item => item.UserName">
@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">
@context.UserName @context.UserName
</GridColumn> </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 @context.FullName
</GridColumn> </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"> <GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="وضعیت">
@context.PhoneNumber
</GridColumn> *@
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="وضعیت">
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" /> <Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
</GridColumn> </GridColumn>
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="عملیات"> <GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="عملیات">
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteExper(context.UserID,context.FullName)"> حذف </Button> <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.UserID,context.FullName)"> گروه ها </Button> <Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.ID,context.FullName)"> گروه ها </Button>
</GridColumn> </GridColumn>
</GridColumns> </GridColumns>
@@ -71,35 +54,32 @@ AllowRowClick=true>
private ConfirmDialog dialog = default!; private ConfirmDialog dialog = default!;
Dictionary<string, object> parameters = new Dictionary<string, object>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
Grid<HushianUserDto> grid = default!; Grid<Read_ExperDto> grid = default!;
private Modal modal = default!; private Modal modal = default!;
string title = "کارشناس جدید"; string title = "کارشناس جدید";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack)); 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"); navigationManager.NavigateTo("/NotFound");
await base.OnInitializedAsync(); 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); 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() async Task CallBack()
{ {
await modal.HideAsync(); await modal.HideAsync();
await grid.RefreshDataAsync(); 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
FullName = args.Item.FullName,
UserName = args.Item.UserName,
img = args.Item.img
}; };
Dictionary<string, object> eparameters = new Dictionary<string, object>(); Dictionary<string, object> eparameters = new Dictionary<string, object>();
eparameters.Add("model", editmodel); eparameters.Add("model", editmodel);
@@ -108,17 +88,17 @@ AllowRowClick=true>
await modal.ShowAsync<UpdateExperComponent>($"ویرایش کارشناس {args.Item.FullName}", parameters: eparameters); 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 (model.Available != value)
{ {
if (await userService.ChangeAvailableExperFromManager(model.UserID, value)) if (await userService.ChangeAvailableExperFromManager(model.ID, value))
model.Available = 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( var confirmation = await dialog.ShowAsync(
title: $"مطمئنی می‌خوای {name} حذف کنی؟", title: $"مطمئنی می‌خوای {name} حذف کنی؟",
@@ -144,7 +124,7 @@ AllowRowClick=true>
} }
return string.Empty; 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>(); Dictionary<string, object> eparameters = new Dictionary<string, object>();
eparameters.Add("ExperID", ExperID); eparameters.Add("ExperID", ExperID);

View File

@@ -24,12 +24,12 @@ namespace HushianWebApp.Service
var response = await _baseController.Put($"{BaseRoute}UpdateGroup", Group); var response = await _baseController.Put($"{BaseRoute}UpdateGroup", Group);
return response.IsSuccessStatusCode; 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}"); var response = await _baseController.Put($"{BaseRoute}JoinExperToGroup/{GroupID}/{ExperID}");
return response.IsSuccessStatusCode; 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}"); var response = await _baseController.Put($"{BaseRoute}UnJoinExperToGroup/{GroupID}/{ExperID}");
return response.IsSuccessStatusCode; return response.IsSuccessStatusCode;
@@ -57,7 +57,7 @@ namespace HushianWebApp.Service
} }
return null; 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}"); var response = await _baseController.Get($"{BaseRoute}GetGroupsFromExperID?ExperID={ExperID}");
if (response.IsSuccessStatusCode) 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}"); var response = await _baseController.Put($"{BaseRoute}ChangeAvailableExperFromManager/{ExperID}?Available={Available}");
return response.IsSuccessStatusCode; 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}"); var response = await _baseController.Delete($"{BaseRoute}DeleteExperFromManager/{ExperID}");
return response.IsSuccessStatusCode; return response.IsSuccessStatusCode;