diff --git a/Hushian.Application/Validation/FixedValidation.cs b/Common/Validation/FixedValidation.cs similarity index 98% rename from Hushian.Application/Validation/FixedValidation.cs rename to Common/Validation/FixedValidation.cs index c6d4311..5191a73 100644 --- a/Hushian.Application/Validation/FixedValidation.cs +++ b/Common/Validation/FixedValidation.cs @@ -1,5 +1,5 @@ using System.Text.RegularExpressions; -namespace Hushian.Application.Validation +namespace Common.Validation { public static class FixedValidation { diff --git a/Hushian.Application/Services/AuthService.cs b/Hushian.Application/Services/AuthService.cs index c0c5c6f..15a5cc3 100644 --- a/Hushian.Application/Services/AuthService.cs +++ b/Hushian.Application/Services/AuthService.cs @@ -1,12 +1,11 @@ using Common.Models.Auth; using Common.Models.Auth.CompanySide; using Common.Models.Auth.UserSide; +using Common.Validation; using Hushian.Application.Constants; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; -using Hushian.Application.Validation; using Hushian.Domain.Entites; -using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; diff --git a/Hushian.Application/Services/CompanyService.cs b/Hushian.Application/Services/CompanyService.cs index 44dc3a8..b9b1ac3 100644 --- a/Hushian.Application/Services/CompanyService.cs +++ b/Hushian.Application/Services/CompanyService.cs @@ -1,18 +1,11 @@ using AutoMapper; using Common.Dtos; using Common.Dtos.Company; -using Common.Dtos.Exper; +using Common.Validation; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; -using Hushian.Application.Validation; using Hushian.Domain.Entites; 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 { diff --git a/Hushian.Application/Services/ConversationService.cs b/Hushian.Application/Services/ConversationService.cs index 1c52f5e..766c925 100644 --- a/Hushian.Application/Services/ConversationService.cs +++ b/Hushian.Application/Services/ConversationService.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using Common.Dtos.Conversation; +using Common.Dtos.Conversation; using Common.Enums; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; @@ -7,12 +6,6 @@ using Hushian.Domain.Entites; using Hushian.WebApi; using Microsoft.AspNetCore.SignalR; 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 { @@ -149,7 +142,7 @@ namespace Hushian.Application.Services UserFullName = s.User.FullName }).ToListAsync(); - public async Task> GetConversationItems(int ConversationID, int? ExperID) + public async Task> GetConversationItems(int ConversationID) { return await _ConversationResponseRepository.Get() .Include(inc=>inc.Exper) diff --git a/Hushian.Application/Services/ExperService.cs b/Hushian.Application/Services/ExperService.cs index 0b4dfdd..d03f426 100644 --- a/Hushian.Application/Services/ExperService.cs +++ b/Hushian.Application/Services/ExperService.cs @@ -3,15 +3,9 @@ using Common.Dtos; using Common.Dtos.Exper; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; -using Hushian.Application.Validation; +using Common.Validation; using Hushian.Domain.Entites; 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 { diff --git a/Hushian.Application/Services/GroupService.cs b/Hushian.Application/Services/GroupService.cs index aaf5e59..7d4653d 100644 --- a/Hushian.Application/Services/GroupService.cs +++ b/Hushian.Application/Services/GroupService.cs @@ -3,14 +3,9 @@ using Common.Dtos.Exper; using Common.Dtos.Group; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; -using Hushian.Application.Validation; +using Common.Validation; using Hushian.Domain.Entites; using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Hushian.Application.Services { diff --git a/Hushian.Application/Services/VerificationService.cs b/Hushian.Application/Services/VerificationService.cs index 281abbf..9afdb89 100644 --- a/Hushian.Application/Services/VerificationService.cs +++ b/Hushian.Application/Services/VerificationService.cs @@ -4,17 +4,13 @@ using Common.Enums; using Common.Models.Auth; using Hushian.Application.Contracts.Persistence; using Hushian.Application.Models; -using Hushian.Application.Validation; +using Common.Validation; using Hushian.Domain.Entites; using Identity.Models; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Hushian.Application.Services { diff --git a/Presentation/HushianWebApp/Components/ADDExperComponent.razor b/Presentation/HushianWebApp/Components/ADDExperComponent.razor index 3ca79dd..8051d96 100644 --- a/Presentation/HushianWebApp/Components/ADDExperComponent.razor +++ b/Presentation/HushianWebApp/Components/ADDExperComponent.razor @@ -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;
@@ -13,21 +13,11 @@
- +
- -
-
- - - - @if (model.img != null && model.img.Length > 0) - { - Uploaded Image - } - +
@@ -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 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 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; + // } } \ No newline at end of file diff --git a/Presentation/HushianWebApp/Components/ADDGroupComponent.razor b/Presentation/HushianWebApp/Components/ADDGroupComponent.razor index ad59629..d72a0a0 100644 --- a/Presentation/HushianWebApp/Components/ADDGroupComponent.razor +++ b/Presentation/HushianWebApp/Components/ADDGroupComponent.razor @@ -1,4 +1,4 @@ -@using Hushian.Application.Dtos +@using Common.Dtos.Group @using HushianWebApp.Service @inject GroupService groupService;
@@ -27,7 +27,7 @@
@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; } diff --git a/Presentation/HushianWebApp/Components/Base/ChatBubble.razor b/Presentation/HushianWebApp/Components/Base/ChatBubble.razor index 518fa17..664f635 100644 --- a/Presentation/HushianWebApp/Components/Base/ChatBubble.razor +++ b/Presentation/HushianWebApp/Components/Base/ChatBubble.razor @@ -1,30 +1,30 @@ -@using Hushian.Application.Dtos +@using Common.Dtos.Conversation @inject IJSRuntime JSRuntime
@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;
- @if (!msg.IsRead && msg.Type == Hushian.Enums.ConversationType.UE) + @if (!msg.IsRead && msg.Type == Common.Enums.ConversationType.UE) {

ـــــــــــــــــــــــــ

}
} - -
-
+ +
+
@msg.text
- @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 Messages { get; set; } = new(); + public List Messages { get; set; } = new(); [Parameter] public EventCallback 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); diff --git a/Presentation/HushianWebApp/Components/ChangePassWordComponent.razor b/Presentation/HushianWebApp/Components/ChangePassWordComponent.razor index b72899f..91de216 100644 --- a/Presentation/HushianWebApp/Components/ChangePassWordComponent.razor +++ b/Presentation/HushianWebApp/Components/ChangePassWordComponent.razor @@ -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 @@
- + - + @@ -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("Username"); - dto = new() { UserName = Username }; + // Username = await localStorageService.GetItem("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 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) diff --git a/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor b/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor index 46225ad..6fa166f 100644 --- a/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor +++ b/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor @@ -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 @@
-
- -
- -
- - - - @if (model.img != null && model.img.Length > 0) - { - Uploaded Image - } - -
+ - @if (isAuthorizedCompanyUser) - { - - - } +
@code { + bool isAuthorizedCompanyUser = false; - [Parameter] public EventCallback OnMultipleOfThree { get; set; } - public List Roles { get; set; } = new(); + [Parameter] public EventCallback 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>("Role"); - isAuthorizedCompanyUser = Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany(); + Role = await localStorageService.GetItem("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; - } } diff --git a/Presentation/HushianWebApp/Components/GroupUsersComponent.razor b/Presentation/HushianWebApp/Components/GroupUsersComponent.razor index d38a5a0..b417132 100644 --- a/Presentation/HushianWebApp/Components/GroupUsersComponent.razor +++ b/Presentation/HushianWebApp/Components/GroupUsersComponent.razor @@ -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 @@
+ OnChanged="(Read_ExperDto exper) => OnAutoCompleteChanged(exper)" />
- @@ -37,9 +37,9 @@ private bool Spinnervisible = false; [Parameter] public int GroupID { get; set; } - public List Expers { get; set; } + public List Expers { get; set; } = new(); - public List CoExpers { get; set; } + public List CoExpers { get; set; } = new(); protected override async Task OnParametersSetAsync() { @@ -50,25 +50,25 @@ } } @functions { - private async Task> DataProvider(AutoCompleteDataProviderRequest request) + private async Task> DataProvider(AutoCompleteDataProviderRequest request) { - CoExpers = (await userService.GetExpersCompany(0, 0, 0)).list; - return await Task.FromResult(new AutoCompleteDataProviderResult { 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 { 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; } diff --git a/Presentation/HushianWebApp/Components/UpdateExperComponent.razor b/Presentation/HushianWebApp/Components/UpdateExperComponent.razor index 6a0f7bc..38c1bb9 100644 --- a/Presentation/HushianWebApp/Components/UpdateExperComponent.razor +++ b/Presentation/HushianWebApp/Components/UpdateExperComponent.razor @@ -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;
@@ -11,20 +12,7 @@
-
- - -
-
- - - - @if (model.img != null && model.img.Length > 0) - { - Uploaded Image - } - -
+ @@ -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; - } + } \ No newline at end of file diff --git a/Presentation/HushianWebApp/Components/UpdateGroupComponent.razor b/Presentation/HushianWebApp/Components/UpdateGroupComponent.razor index 1c431a8..7fde2b1 100644 --- a/Presentation/HushianWebApp/Components/UpdateGroupComponent.razor +++ b/Presentation/HushianWebApp/Components/UpdateGroupComponent.razor @@ -1,4 +1,4 @@ -@using Hushian.Application.Dtos +@using Common.Dtos.Group @using HushianWebApp.Service @inject GroupService groupService;
@@ -28,7 +28,7 @@
@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; } diff --git a/Presentation/HushianWebApp/Components/UserGroupsComponent.razor b/Presentation/HushianWebApp/Components/UserGroupsComponent.razor index cfba780..0484abb 100644 --- a/Presentation/HushianWebApp/Components/UserGroupsComponent.razor +++ b/Presentation/HushianWebApp/Components/UserGroupsComponent.razor @@ -1,4 +1,5 @@ -@using Hushian.Application.Dtos + +@using Common.Dtos.Group @using HushianWebApp.Service @inject GroupService groupService; @@ -7,14 +8,14 @@
+ OnChanged="(Read_GroupDto group) => OnAutoCompleteChanged(group)" />
- @@ -35,10 +36,10 @@ private string? GroupName; private bool Spinnervisible = false; - [Parameter] public string ExperID { get; set; } - public List Groups { get; set; } + [Parameter] public int ExperID { get; set; } + public List Groups { get; set; } = new(); - public List CoGroups { get; set; } + public List CoGroups { get; set; } = new(); protected override async Task OnParametersSetAsync() { @@ -49,13 +50,13 @@ } } @functions { - private async Task> DataProvider(AutoCompleteDataProviderRequest request) + private async Task> DataProvider(AutoCompleteDataProviderRequest request) { CoGroups = await groupService.GetGroupsCompany(); - return await Task.FromResult(new AutoCompleteDataProviderResult { Data = CoGroups.Where(w=>w.Name.Contains(request.Filter.Value)), TotalCount = CoGroups.Count() }); + return await Task.FromResult(new AutoCompleteDataProviderResult { 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)) diff --git a/Presentation/HushianWebApp/Components/UserPanel/ConversionHistoryComponent.razor b/Presentation/HushianWebApp/Components/UserPanel/ConversionHistoryComponent.razor index 06bb110..da71bd8 100644 --- a/Presentation/HushianWebApp/Components/UserPanel/ConversionHistoryComponent.razor +++ b/Presentation/HushianWebApp/Components/UserPanel/ConversionHistoryComponent.razor @@ -1,4 +1,5 @@ -@using Hushian.Application.Dtos +@using Common.Dtos.Conversation + پیام های اخیر شما ...
@foreach (var item in Conversations) @@ -6,13 +7,13 @@
- @GetTitleCon(item.Title) + @GetTitleCon(item.LastText)
    -
  • @item.ExperFullName (@item.Cdate item.Ctime)
  • +
  • @item.ExperFullName (@item.LastMsgdate @item.LastMsgtime)
- @if (item.status == Hushian.Enums.ConversationStatus.InProgress && item.NoReadCount > 0) + @if (item.status == Common.Enums.ConversationStatus.InProgress && item.NoReadCount > 0) { OnMultipleOfThree { get; set; } - [Parameter] public List Conversations { get; set; } + [Parameter] public List Conversations { get; set; } string GetTitleCon(string str) { if (str.Length > 15) return str.Substring(0, 15) + "..."; diff --git a/Presentation/HushianWebApp/Components/Verification.razor b/Presentation/HushianWebApp/Components/Verification.razor index 9cae14e..2cb0988 100644 --- a/Presentation/HushianWebApp/Components/Verification.razor +++ b/Presentation/HushianWebApp/Components/Verification.razor @@ -1,4 +1,5 @@ -@using Common.Dtos.User + +@using Common.Dtos.Verification @using Common.Enums @using HushianWebApp.Service @inject VerificationService verificationService; diff --git a/Presentation/HushianWebApp/Layout/MainLayout.razor b/Presentation/HushianWebApp/Layout/MainLayout.razor index bd14c7d..b2695ca 100644 --- a/Presentation/HushianWebApp/Layout/MainLayout.razor +++ b/Presentation/HushianWebApp/Layout/MainLayout.razor @@ -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(); - parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack)); + parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack)); await modal.ShowAsync(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"); diff --git a/Presentation/HushianWebApp/Models/WindowSize.cs b/Presentation/HushianWebApp/Models/WindowSize.cs new file mode 100644 index 0000000..e94fd90 --- /dev/null +++ b/Presentation/HushianWebApp/Models/WindowSize.cs @@ -0,0 +1,8 @@ +namespace HushianWebApp.Models +{ + public class WindowSize + { + public int Width { get; set; } + public int Height { get; set; } + } +} diff --git a/Presentation/HushianWebApp/Pages/Auth/Login.razor b/Presentation/HushianWebApp/Pages/Auth/Login.razor index 0354e1f..7cdca19 100644 --- a/Presentation/HushianWebApp/Pages/Auth/Login.razor +++ b/Presentation/HushianWebApp/Pages/Auth/Login.razor @@ -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 @@
- Hushian + Hushian ورود به هوشیان @@ -59,7 +59,7 @@
- ثبت نام + ثبت نام
@@ -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(); - parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed); - parameters.Add("sendValue", username); - parameters.Add("ID", 0); - parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBackVer)); - parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید"); - await modal.ShowAsync(title: "احراز", parameters: parameters); - } - - async Task CallBackVer(VerificationCodeType type) - { - await modal.HideAsync(); - } + // async Task verification() + // { + // var parameters = new Dictionary(); + // parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed); + // parameters.Add("sendValue", username); + // parameters.Add("ID", 0); + // parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBackVer)); + // parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید"); + // await modal.ShowAsync(title: "احراز", parameters: parameters); + // } + + // async Task CallBackVer(VerificationCodeType type) + // { + // await modal.HideAsync(); + // } } diff --git a/Presentation/HushianWebApp/Pages/Auth/Register.razor b/Presentation/HushianWebApp/Pages/Auth/Register.razor index 8c666ed..31955e4 100644 --- a/Presentation/HushianWebApp/Pages/Auth/Register.razor +++ b/Presentation/HushianWebApp/Pages/Auth/Register.razor @@ -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) diff --git a/Presentation/HushianWebApp/Pages/Conversation.razor b/Presentation/HushianWebApp/Pages/Conversation.razor index 762a1d7..b542ebf 100644 --- a/Presentation/HushianWebApp/Pages/Conversation.razor +++ b/Presentation/HushianWebApp/Pages/Conversation.razor @@ -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 @@
@item.UserFullName - @item.Cdate - @item.Ctime + @item.LastMsgdate + @item.LastMsgtime
-
@item.Title
+
@item.LastText
@if (item.NoReadCount > 0) { @@ -89,10 +89,10 @@
@item.UserFullName - @item.Cdate - @item.Ctime + @item.LastMsgdate + @item.LastMsgtime
-
@item.Title
+
@item.LastText
@if (item.NoReadCount>0) { @@ -115,10 +115,10 @@
@item.UserFullName - @item.Cdate - @item.Ctime + @item.LastMsgdate + @item.LastMsgtime
-
@item.Title
+
@item.LastText
@@ -159,19 +159,19 @@ public int countInbox1 { get { return Inbox1Items.Count(); } } public int countInbox2 { get { return Inbox2Items.Count(); } } - public List Inbox1Items { get; set; } + public List Inbox1Items { get; set; } = new() ; - public List Inbox2Items { get; set; } + public List Inbox2Items { get; set; } = new(); - public List Inbox3Items { get; set; } + public List Inbox3Items { get; set; } = new(); - public ConversationDto? SelectedConversation { get; set; } = null; - public List? SelectedConversationItems { get; set; } + public Read_ConversationDto? SelectedConversation { get; set; } = null; + public List? SelectedConversationItems { get; set; } = null; public string SelectedChatUserName { get; set; } = "مهدی ربیع نژاد"; - public List 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>("Role"); + Role = await localStorageService.GetItem("Role"); - UserID= await localStorageService.GetItem("UserID"); + UserID= await localStorageService.GetItem("UserID"); convloading = true; await LoadSessionB(); Inbox1Items =await conversationService.ConversationAwaitingOurResponse(); @@ -307,14 +307,14 @@ {

@SelectedChatUserName

- @if ( SelectedConversation.status==Hushian.Enums.ConversationStatus.InProgress) + @if ( SelectedConversation.status==Common.Enums.ConversationStatus.InProgress) { @@ -324,14 +324,14 @@ ارجاع به... } - 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)) { - - + @if (context.img?.Length!=0) { Uploaded Image @@ -36,23 +36,23 @@ AllowRowClick=true> } - + @context.ID - + @context.Name - + @context.Info - + - + @@ -65,11 +65,11 @@ AllowRowClick=true> private ConfirmDialog dialog = default!; Dictionary parameters = new Dictionary(); - Grid grid = default!; + Grid grid = default!; private Modal modal = default!; string title = "گروه جدید"; - public List list = new(); - private async Task> DataProvider(GridDataProviderRequest request) + public List list = new(); + private async Task> DataProvider(GridDataProviderRequest 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 args) + private async Task OnRowClick(GridRowEventArgs args) { Dictionary eparameters = new Dictionary(); 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) { diff --git a/Presentation/HushianWebApp/Pages/Manage/Settings.razor b/Presentation/HushianWebApp/Pages/Manage/Settings.razor index cde5dda..5cb63a1 100644 --- a/Presentation/HushianWebApp/Pages/Manage/Settings.razor +++ b/Presentation/HushianWebApp/Pages/Manage/Settings.razor @@ -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 @@
- + +
+
+
@@ -79,22 +82,17 @@
-
- -
-
- -
+
- @if (dto.img != null && dto.img.Length > 0) + @if (dto.logo != null && dto.logo.Length > 0) { Uploaded Image }
@@ -127,18 +125,20 @@
@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>("Role")).Any(a => a == "HushianManagerCompany")) + if (await localStorageService.GetItem("Role") != "Company") navigationManager.NavigateTo("/NotFound"); + CompanyID= await localStorageService.GetItem("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; } diff --git a/Presentation/HushianWebApp/Pages/Manage/UserManagment.razor b/Presentation/HushianWebApp/Pages/Manage/UserManagment.razor index e464dc3..d442c2a 100644 --- a/Presentation/HushianWebApp/Pages/Manage/UserManagment.razor +++ b/Presentation/HushianWebApp/Pages/Manage/UserManagment.razor @@ -1,7 +1,6 @@ @page "/UserManagement" -@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 @@ کارشناس جدید - - - @if (context.img?.Length != 0) - { - Uploaded Image - } - else - { - - } - - + @context.UserName - + @context.FullName - - @context.Email - + - @* - @context.PhoneNumber - *@ - - + - - - + + + @@ -71,35 +54,32 @@ AllowRowClick=true> private ConfirmDialog dialog = default!; Dictionary parameters = new Dictionary(); - Grid grid = default!; + Grid 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>("Role")).Any(a =>a== "HushianManagerCompany") ) + if (await localStorageService.GetItem("Role")!= "Company" ) navigationManager.NavigateTo("/NotFound"); await base.OnInitializedAsync(); } - private async Task> DataProvider(GridDataProviderRequest request) + private async Task> DataProvider(GridDataProviderRequest 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 args) + private async Task OnRowClick(GridRowEventArgs 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 eparameters = new Dictionary(); eparameters.Add("model", editmodel); @@ -108,17 +88,17 @@ AllowRowClick=true> await modal.ShowAsync($"ویرایش کارشناس {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 eparameters = new Dictionary(); eparameters.Add("ExperID", ExperID); diff --git a/Presentation/HushianWebApp/Service/GroupService.cs b/Presentation/HushianWebApp/Service/GroupService.cs index b34c699..f00a528 100644 --- a/Presentation/HushianWebApp/Service/GroupService.cs +++ b/Presentation/HushianWebApp/Service/GroupService.cs @@ -24,12 +24,12 @@ namespace HushianWebApp.Service var response = await _baseController.Put($"{BaseRoute}UpdateGroup", Group); return response.IsSuccessStatusCode; } - public async Task JoinExperToGroup(int GroupID, string ExperID) + public async Task JoinExperToGroup(int GroupID, int ExperID) { var response = await _baseController.Put($"{BaseRoute}JoinExperToGroup/{GroupID}/{ExperID}"); return response.IsSuccessStatusCode; } - public async Task UnJoinExperToGroup(int GroupID, string ExperID) + public async Task 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?> GetGroupsFromExperID(string ExperID) + public async Task?> GetGroupsFromExperID(int ExperID) { var response = await _baseController.Get($"{BaseRoute}GetGroupsFromExperID?ExperID={ExperID}"); if (response.IsSuccessStatusCode) diff --git a/Presentation/HushianWebApp/Service/UserService.cs b/Presentation/HushianWebApp/Service/UserService.cs index d42aeda..c81dbdb 100644 --- a/Presentation/HushianWebApp/Service/UserService.cs +++ b/Presentation/HushianWebApp/Service/UserService.cs @@ -71,13 +71,13 @@ namespace HushianWebApp.Service } - public async Task ChangeAvailableExperFromManager(string ExperID,bool Available) + public async Task ChangeAvailableExperFromManager(int ExperID,bool Available) { var response = await _baseController.Put($"{BaseRoute}ChangeAvailableExperFromManager/{ExperID}?Available={Available}"); return response.IsSuccessStatusCode; } - public async TaskDeleteExperFromManager(string ExperID) + public async TaskDeleteExperFromManager(int ExperID) { var response = await _baseController.Delete($"{BaseRoute}DeleteExperFromManager/{ExperID}"); return response.IsSuccessStatusCode;