ProgrmmaagerUserAccount completed
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AccountManagement.Application.Contracts.Role;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.Account;
|
||||
|
||||
@@ -40,4 +41,15 @@ public class CreateAccount
|
||||
/// آیا کاربر در پروگرام منیجر فعالیت مبکند؟
|
||||
/// </summary>
|
||||
public bool IsProgramManagerUser { get; set; }
|
||||
/// <summary>
|
||||
/// لیست نقش های پروگرام منیجر
|
||||
/// </summary>
|
||||
public List<long> UserRoles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست نقشهای موجود در پروگرام منیجر
|
||||
/// </summary>
|
||||
public SelectList RoleList { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace AccountManagement.Application.Contracts.Account;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.Account;
|
||||
|
||||
public class EditAccount : CreateAccount
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
@@ -5,5 +5,7 @@ public record ApiResponse
|
||||
public bool isSuccess { get; set; }
|
||||
public string errorMessage { get; set; }
|
||||
|
||||
|
||||
|
||||
public ErrorType ErrorType { get; set; }
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public record CreateProgramManagerUser(string FullName, string UserName, string Password, string Mobile, string Email, long? AccountId);
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
public record CreateProgramManagerUser(string FullName, string UserName, string Password, string Mobile, string Email, long? AccountId, List<long> Roles);
|
||||
|
||||
public record EditUserCommand(string FullName, string UserName, string Mobile, long AccountId, List<long> Roles, bool IsActive);
|
||||
@@ -1,4 +1,5 @@
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Collections.Generic;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
@@ -49,4 +50,6 @@ public record SingleUserData
|
||||
/// ای دی اکانت کاربر در گزارشگیر
|
||||
/// </summary>
|
||||
public long? accountId { get; set; }
|
||||
|
||||
public List<long> Roles { get; set; }
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AccountApplication : IAccountApplication
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly ICameraAccountRepository _cameraAccountRepository;
|
||||
private readonly IPositionRepository _positionRepository;
|
||||
private readonly IAccountLeftworkRepository _accountLeftworkRepository;
|
||||
private readonly IAccountLeftworkRepository _accountLeftworkRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
private readonly ISubAccountRepository _subAccountRepository;
|
||||
private readonly ISubAccountRoleRepository _subAccountRoleRepository;
|
||||
@@ -72,7 +72,7 @@ public class AccountApplication : IAccountApplication
|
||||
_fileUploader = fileUploader;
|
||||
_passwordHasher = passwordHasher;
|
||||
_accountRepository = accountRepository;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public OperationResult EditClient(EditClientAccount command)
|
||||
@@ -101,7 +101,7 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
var path = $"profilePhotos";
|
||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
editAccount.EditClient(command.Fullname,command.Username,command.Mobile,picturePath,command.Email,command.NationalCode);
|
||||
editAccount.EditClient(command.Fullname, command.Username, command.Mobile, picturePath, command.Email, command.NationalCode);
|
||||
_accountRepository.SaveChanges();
|
||||
return opreation.Succcedded();
|
||||
}
|
||||
@@ -145,15 +145,15 @@ public class AccountApplication : IAccountApplication
|
||||
var picturePath = "";
|
||||
if (_fileUploader != null)
|
||||
{
|
||||
picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
|
||||
picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
|
||||
}
|
||||
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
||||
picturePath, roleName.Name, "true", "false");
|
||||
|
||||
_unitOfWork.BeginAccountContext();
|
||||
|
||||
|
||||
|
||||
_accountRepository.Create(account);
|
||||
_accountRepository.SaveChanges();
|
||||
|
||||
@@ -165,10 +165,11 @@ public class AccountApplication : IAccountApplication
|
||||
password,
|
||||
command.Mobile,
|
||||
command.Email,
|
||||
account.id
|
||||
account.id,
|
||||
command.UserRoles
|
||||
);
|
||||
|
||||
var url = "api/user";
|
||||
var url = "api/user/create";
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
@@ -204,8 +205,8 @@ public class AccountApplication : IAccountApplication
|
||||
return opreation.Failed("پر کردن تمامی فیلدها الزامی است");
|
||||
if (_accountRepository.Exists(x => x.Username == command.Username))
|
||||
return opreation.Failed("نام کاربری تکراری است");
|
||||
if (_accountRepository.Exists(x => x.Mobile == command.Mobile && x.IsActiveString =="true"))
|
||||
|
||||
if (_accountRepository.Exists(x => x.Mobile == command.Mobile && x.IsActiveString == "true"))
|
||||
|
||||
return opreation.Failed("مقادیر وارد شده تکراری است");
|
||||
|
||||
//var nationalCodeValidation = command.NationalCode.NationalCodeValid();
|
||||
@@ -222,11 +223,11 @@ public class AccountApplication : IAccountApplication
|
||||
// break;
|
||||
//}
|
||||
var password = _passwordHasher.Hash(command.Password);
|
||||
var register =new Account(command.Fullname,command.Username, password, command.Mobile, command.NationalCode);
|
||||
var register = new Account(command.Fullname, command.Username, password, command.Mobile, command.NationalCode);
|
||||
_accountRepository.Create(register);
|
||||
_accountRepository.SaveChanges();
|
||||
|
||||
return opreation.Succcedded(register.id,message: "ثبت نام شما با موفقیت انجام شد");
|
||||
return opreation.Succcedded(register.id, message: "ثبت نام شما با موفقیت انجام شد");
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditAccount command)
|
||||
@@ -243,8 +244,97 @@ public class AccountApplication : IAccountApplication
|
||||
var roleName = _roleRepository.GetDetails(command.RoleId);
|
||||
var path = $"profilePhotos";
|
||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
_unitOfWork.BeginAccountContext();
|
||||
account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath, roleName.Name);
|
||||
_accountRepository.SaveChanges();
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
$"api/user/{account.id}",
|
||||
key
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده
|
||||
if (apiResult.Success && apiResult.Result.Data.accountId == account.id)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
|
||||
var parameters = new EditUserCommand(
|
||||
command.Fullname,
|
||||
command.Username,
|
||||
command.Mobile,
|
||||
account.id,
|
||||
command.UserRoles,
|
||||
command.IsProgramManagerUser
|
||||
);
|
||||
var url = "api/user/edit";
|
||||
var response = InternalApiCaller.PostAsync<EditUserCommand, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
}
|
||||
|
||||
}
|
||||
else //اگر کاربر قبلا ایجاد نشده
|
||||
{
|
||||
//اگر تیک فعالیت در پروگرام منیجر روشن بود
|
||||
if (command.IsProgramManagerUser)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
var parameters = new CreateProgramManagerUser(
|
||||
command.Fullname,
|
||||
command.Username,
|
||||
account.Password,
|
||||
command.Mobile,
|
||||
command.Email,
|
||||
account.id,
|
||||
command.UserRoles
|
||||
);
|
||||
|
||||
var url = "api/user/Create";
|
||||
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
@@ -259,18 +349,18 @@ public class AccountApplication : IAccountApplication
|
||||
long idAutoriz = 0;
|
||||
var operation = new OperationResult();
|
||||
if (string.IsNullOrWhiteSpace(command.Password))
|
||||
return operation.Failed(ApplicationMessages.EmptyPassword);
|
||||
return operation.Failed(ApplicationMessages.EmptyPassword);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.Username))
|
||||
return operation.Failed(ApplicationMessages.EmptyUsername);
|
||||
return operation.Failed(ApplicationMessages.EmptyUsername);
|
||||
|
||||
var account = _accountRepository.GetBy(command.Username);
|
||||
var account = _accountRepository.GetBy(command.Username);
|
||||
var cameraAccount = _cameraAccountRepository.GetBy(command.Username);
|
||||
SubAccount subAccount = _subAccountRepository.GetBy(command.Username);
|
||||
if (account == null && cameraAccount == null && subAccount == null)
|
||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||
SubAccount subAccount = _subAccountRepository.GetBy(command.Username);
|
||||
if (account == null && cameraAccount == null && subAccount == null)
|
||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||
|
||||
if (account != null)
|
||||
if (account != null)
|
||||
{
|
||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(account.Password, command.Password);
|
||||
if (!result.Verified)
|
||||
@@ -294,8 +384,8 @@ public class AccountApplication : IAccountApplication
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||
account.IsActiveString == "true")
|
||||
{
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
@@ -304,14 +394,14 @@ public class AccountApplication : IAccountApplication
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
authViewModel.WorkshopId = workshop.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
|
||||
@@ -330,7 +420,7 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,cameraAccount.IsActiveSting);
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
@@ -340,41 +430,41 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
idAutoriz = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (subAccount != null)
|
||||
{
|
||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(subAccount.Password, command.Password);
|
||||
if (!result.Verified)
|
||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||
var role = _subAccountRoleRepository.Get(subAccount.SubAccountRoleId);
|
||||
if (subAccount != null)
|
||||
{
|
||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(subAccount.Password, command.Password);
|
||||
if (!result.Verified)
|
||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||
var role = _subAccountRoleRepository.Get(subAccount.SubAccountRoleId);
|
||||
|
||||
var permissions = role.RolePermissions.Select(x => x.PermissionCode).ToList();
|
||||
var authViewModel = new AuthViewModel(subAccount.AccountId, subAccount.SubAccountRoleId, subAccount.FullName
|
||||
, subAccount.Username, subAccount.PhoneNumber, "", permissions, role.Title, "false",
|
||||
"true", 0, subAccount.id);
|
||||
var workshopList = _workshopSubAccountRepository.GetWorkshopsBySubAccountId(subAccount.id);
|
||||
authViewModel.WorkshopList = workshopList.Select(x => new WorkshopClaim()
|
||||
{
|
||||
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
|
||||
Name = x.WorkshopName,
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.WorkshopId
|
||||
}).ToList();
|
||||
var permissions = role.RolePermissions.Select(x => x.PermissionCode).ToList();
|
||||
var authViewModel = new AuthViewModel(subAccount.AccountId, subAccount.SubAccountRoleId, subAccount.FullName
|
||||
, subAccount.Username, subAccount.PhoneNumber, "", permissions, role.Title, "false",
|
||||
"true", 0, subAccount.id);
|
||||
var workshopList = _workshopSubAccountRepository.GetWorkshopsBySubAccountId(subAccount.id);
|
||||
authViewModel.WorkshopList = workshopList.Select(x => new WorkshopClaim()
|
||||
{
|
||||
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
|
||||
Name = x.WorkshopName,
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.WorkshopId
|
||||
}).ToList();
|
||||
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.WorkshopName;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.WorkshopName;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
|
||||
authViewModel.WorkshopId = workshop.WorkshopId;
|
||||
}
|
||||
_authHelper.Signin(authViewModel);
|
||||
idAutoriz = 2;
|
||||
}
|
||||
}
|
||||
_authHelper.Signin(authViewModel);
|
||||
idAutoriz = 2;
|
||||
}
|
||||
|
||||
return operation.Succcedded(idAutoriz);
|
||||
return operation.Succcedded(idAutoriz);
|
||||
}
|
||||
public OperationResult LoginWithMobile(long id)
|
||||
{
|
||||
@@ -405,24 +495,24 @@ public class AccountApplication : IAccountApplication
|
||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||
account.IsActiveString == "true")
|
||||
{
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
if (workshopList.Any())
|
||||
{
|
||||
var workshop = workshopList.First();
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
authViewModel.WorkshopId = workshop.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_authHelper.Signin(authViewModel);
|
||||
long idAutoriz = 0;
|
||||
@@ -478,7 +568,7 @@ public class AccountApplication : IAccountApplication
|
||||
return _accountRepository.GetByUserNameAndId(id, username);
|
||||
}
|
||||
|
||||
public async Task <OperationResult> SetVerifyCode(string phone, long id)
|
||||
public async Task<OperationResult> SetVerifyCode(string phone, long id)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var account = _accountRepository.Get(id);
|
||||
@@ -492,11 +582,11 @@ public class AccountApplication : IAccountApplication
|
||||
_smsService.LoginSend(phone, r);
|
||||
|
||||
//TimeSpan delay = TimeSpan.FromSeconds(30);
|
||||
|
||||
|
||||
await _accountRepository.RemoveCode(id);
|
||||
|
||||
|
||||
return operation.Succcedded();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -547,67 +637,67 @@ public class AccountApplication : IAccountApplication
|
||||
.Select(x => x.Code)
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
_authHelper.SignOut();
|
||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true",null);
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true", null);
|
||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||
{
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.Id,
|
||||
Name = x.WorkshopFullName,
|
||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
authViewModel.WorkshopList = workshopList;
|
||||
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||
authViewModel.Permissions = clientPermissions;
|
||||
if (authViewModel.WorkshopList.Any())
|
||||
{
|
||||
var workshop = authViewModel.WorkshopList.First();
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
if (authViewModel.WorkshopList.Any())
|
||||
{
|
||||
var workshop = authViewModel.WorkshopList.First();
|
||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||
authViewModel.WorkshopName = workshop.Name;
|
||||
authViewModel.WorkshopId = workshop.Id;
|
||||
}
|
||||
_authHelper.Signin(authViewModel);
|
||||
}
|
||||
_authHelper.Signin(authViewModel);
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
public OperationResult DirectCameraLogin(long cameraAccountId)
|
||||
{
|
||||
var prAcc = _authHelper.CurrentAccountInfo();
|
||||
var operation = new OperationResult();
|
||||
var cameraAccount = _cameraAccountRepository.GetById(cameraAccountId);
|
||||
if (cameraAccount == null)
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
var prAcc = _authHelper.CurrentAccountInfo();
|
||||
var operation = new OperationResult();
|
||||
var cameraAccount = _cameraAccountRepository.GetById(cameraAccountId);
|
||||
if (cameraAccount == null)
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
_authHelper.SignOut();
|
||||
_authHelper.SignOut();
|
||||
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return operation.Failed("این اکانت غیر فعال شده است");
|
||||
}
|
||||
return operation.Succcedded(2);
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return operation.Failed("این اکانت غیر فعال شده است");
|
||||
}
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
||||
{
|
||||
string fullname = this._accountRepository.GetById(accountId).Fullname;
|
||||
List<WorkshopAccountlistViewModel> source =_accountLeftworkRepository.WorkshopList(accountId);
|
||||
List<WorkshopAccountlistViewModel> source = _accountLeftworkRepository.WorkshopList(accountId);
|
||||
List<long> userWorkshopIds = source.Select(x => x.WorkshopId).ToList();
|
||||
List<WorkshopSelectList> allWorkshops = this._accountLeftworkRepository.GetAllWorkshops();
|
||||
List<AccountViewModel> accountSelectList = this._accountRepository.GetAdminAccountSelectList();
|
||||
@@ -690,65 +780,65 @@ public class AccountApplication : IAccountApplication
|
||||
#region Pooya
|
||||
public OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password, string rePassword)
|
||||
{
|
||||
OperationResult op = new();
|
||||
OperationResult op = new();
|
||||
|
||||
var entity = _accountRepository.Get(accountId);
|
||||
var entity = _accountRepository.Get(accountId);
|
||||
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(rePassword) || !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
if (rePassword != password)
|
||||
return op.Failed("تکرار رمز عبور با رمز عبور مطابقت ندارد");
|
||||
if (!string.IsNullOrWhiteSpace(rePassword) || !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
if (rePassword != password)
|
||||
return op.Failed("تکرار رمز عبور با رمز عبور مطابقت ندارد");
|
||||
|
||||
if (password.Length < 8)
|
||||
return op.Failed("رمز عبور نمی تواند کمتر از 8 کاراکتر باشد");
|
||||
}
|
||||
if (password.Length < 8)
|
||||
return op.Failed("رمز عبور نمی تواند کمتر از 8 کاراکتر باشد");
|
||||
}
|
||||
|
||||
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) && string.IsNullOrWhiteSpace(rePassword))
|
||||
return op.Failed("چیزی برای تغییر وجود ندارد");
|
||||
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) && string.IsNullOrWhiteSpace(rePassword))
|
||||
return op.Failed("چیزی برای تغییر وجود ندارد");
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(phoneNumber) && entity.Mobile != phoneNumber)
|
||||
{
|
||||
phoneNumber = phoneNumber.Trim();
|
||||
if (phoneNumber.Length != 11)
|
||||
return op.Failed("شماره تلفن همراه به درستی وارد نشده است");
|
||||
if (_accountRepository.Exists(x => x.Mobile == phoneNumber && x.id != accountId) ||
|
||||
_subAccountRepository.Exists(x => x.PhoneNumber == phoneNumber) ||
|
||||
_cameraAccountRepository.Exists(x => x.Mobile == phoneNumber))
|
||||
return op.Failed("قبلا یک حساب با این شماره ثبت شده است");
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(phoneNumber) && entity.Mobile != phoneNumber)
|
||||
{
|
||||
phoneNumber = phoneNumber.Trim();
|
||||
if (phoneNumber.Length != 11)
|
||||
return op.Failed("شماره تلفن همراه به درستی وارد نشده است");
|
||||
if (_accountRepository.Exists(x => x.Mobile == phoneNumber && x.id != accountId) ||
|
||||
_subAccountRepository.Exists(x => x.PhoneNumber == phoneNumber) ||
|
||||
_cameraAccountRepository.Exists(x => x.Mobile == phoneNumber))
|
||||
return op.Failed("قبلا یک حساب با این شماره ثبت شده است");
|
||||
}
|
||||
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult ChangePasswordAndPhoneNumber(AccountChangePasswordAndPhoneNumber command)
|
||||
{
|
||||
OperationResult op = new();
|
||||
command.PhoneNumber = command.PhoneNumber.Trim();
|
||||
var entity = _accountRepository.Get(command.AccountId);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password, command.RePassword);
|
||||
if (validationResult.IsSuccedded == false)
|
||||
return validationResult;
|
||||
OperationResult op = new();
|
||||
command.PhoneNumber = command.PhoneNumber.Trim();
|
||||
var entity = _accountRepository.Get(command.AccountId);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password, command.RePassword);
|
||||
if (validationResult.IsSuccedded == false)
|
||||
return validationResult;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.RePassword))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(command.RePassword))
|
||||
{
|
||||
|
||||
entity.ChangePassword(_passwordHasher.Hash(command.Password));
|
||||
}
|
||||
entity.ChangePassword(_passwordHasher.Hash(command.Password));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.PhoneNumber))
|
||||
{
|
||||
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto, entity.RoleName);
|
||||
}
|
||||
_accountRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(command.PhoneNumber))
|
||||
{
|
||||
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto, entity.RoleName);
|
||||
}
|
||||
_accountRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
//public UserClaimsResponseDTO GetClaimsForSignIn(Login command)
|
||||
//{
|
||||
// var operation = new OperationResult();
|
||||
@@ -864,12 +954,12 @@ public class AccountApplication : IAccountApplication
|
||||
}
|
||||
|
||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(cameraAccount.Password, request.Password);
|
||||
|
||||
|
||||
if (!result.Verified)
|
||||
throw new BadRequestException(ApplicationMessages.WrongUserPass);
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
|
||||
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
|
||||
cameraAccount.IsActiveSting);
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using Company.Domain._common;
|
||||
using AccountManagement.Application.Contracts.Ticket;
|
||||
|
||||
namespace AccountManagement.Application;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class RoleApplication : IRoleApplication
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
@@ -93,37 +94,119 @@ public class RoleApplication : IRoleApplication
|
||||
_unitOfWork.BeginAccountContext();
|
||||
role.Edit(command.Name, permissions);
|
||||
_roleRepository.SaveChanges();
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
var pmPermissions = command.PmPermissions.Where(x => x > 0).ToList();
|
||||
|
||||
|
||||
//یافتن نقش در پروگرام منیجر
|
||||
var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", command.Id}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (apiResult.Success)
|
||||
{
|
||||
|
||||
if (apiResult.Result.isSuccess)
|
||||
{
|
||||
//اگر این نقش در پروگرام منیجر وجود داشت ویرایش کن
|
||||
if (apiResult.Result.data.role.Any())
|
||||
{
|
||||
var parameters = new CreateProgramManagerRole
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role/edit";
|
||||
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Result.errorMessage);
|
||||
}
|
||||
}
|
||||
else //اگر نقش در پروگرام منیجر وجود نداشت
|
||||
{
|
||||
|
||||
//اگر تیک پرمیشن های پروگرام منیجر زده شده
|
||||
//این نقش را سمت پروگرام منیجر بساز
|
||||
if (pmPermissions.Any())
|
||||
{
|
||||
var parameters = new CreateProgramManagerRole
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role";
|
||||
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Result.errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var parameters = new CreateProgramManagerRole
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role/edit";
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Result.errorMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,89 +59,134 @@
|
||||
data-callback=""
|
||||
data-action="Refresh"
|
||||
enctype="multipart/form-data">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Fullname" class="control-label">نام</label>
|
||||
<input type="text" class="form-control" asp-for="Fullname">
|
||||
<span asp-validation-for="Fullname" class="error"></span>
|
||||
@*@if (TempData["name"] != null)
|
||||
{<br /><span class="error">@TempData["name"]</span>}*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Username" class="control-label">نام کاربری</label>
|
||||
<input type="text" class="form-control" asp-for="Username">
|
||||
<span asp-validation-for="Username" class="error"></span>
|
||||
@*@if (TempData["family"] != null)
|
||||
{<br /><span class="error">@TempData["family"]</span>}*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="RoleId" class="control-label">نقش </label>
|
||||
<select class="form-control" asp-for="RoleId" asp-items='new SelectList(Model.Roles, "Id", "Name")'>
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
|
||||
<span asp-validation-for="RoleId" class="error"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Mobile" class="control-label">شماره تماس</label>
|
||||
<input type="text" class="form-control" asp-for="Mobile">
|
||||
<span asp-validation-for="Mobile" class="error"></span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProfilePhoto" class="control-label"> عکس پروفایل</label>
|
||||
<input type="file" class="form-control" asp-for="ProfilePhoto" accept="image/*">
|
||||
<span asp-validation-for="ProfilePhoto" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"> گذرواژه</label>
|
||||
<input type="text" class="form-control" asp-for="Password">
|
||||
<span asp-validation-for="Password" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div>
|
||||
<span>آیا کاربر در پروگرام منیجر هم فعالیت میکند؟</span>
|
||||
<span> </span>
|
||||
<label class="switch">
|
||||
<input id="checkAll" asp-for="IsProgramManagerUser" type="checkbox" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Fullname" class="control-label">نام</label>
|
||||
<input type="text" class="form-control" asp-for="Fullname">
|
||||
<span asp-validation-for="Fullname" class="error"></span>
|
||||
@*@if (TempData["name"] != null)
|
||||
{<br /><span class="error">@TempData["name"]</span>}*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Username" class="control-label">نام کاربری</label>
|
||||
<input type="text" class="form-control" asp-for="Username">
|
||||
<span asp-validation-for="Username" class="error"></span>
|
||||
@*@if (TempData["family"] != null)
|
||||
{<br /><span class="error">@TempData["family"]</span>}*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@*<input type="hidden" asp-for="id" value="id"/>*@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="RoleId" class="control-label">نقش </label>
|
||||
<select class="form-control" asp-for="RoleId" asp-items='new SelectList(Model.Roles, "Id", "Name")'>
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-success btn-rounded waves-effect waves-light m-b-5"> ثبت کاربر جدید </button>
|
||||
<button type="button" class="btn btn-default btn-rounded waves-effect waves-light m-b-5" data-dismiss="modal">بستن فرم</button>
|
||||
</div>
|
||||
</form>
|
||||
<span asp-validation-for="RoleId" class="error"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Mobile" class="control-label">شماره تماس</label>
|
||||
<input type="text" class="form-control" asp-for="Mobile">
|
||||
<span asp-validation-for="Mobile" class="error"></span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProfilePhoto" class="control-label"> عکس پروفایل</label>
|
||||
<input type="file" class="form-control" asp-for="ProfilePhoto" accept="image/*">
|
||||
<span asp-validation-for="ProfilePhoto" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"> گذرواژه</label>
|
||||
<input type="text" class="form-control" asp-for="Password">
|
||||
<span asp-validation-for="Password" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="row"></div>
|
||||
<div class="form-group" style="margin: 29px 7px 0px;">
|
||||
<span> فعالیت کاربر در پروگرام منیجر </span>
|
||||
<span> </span>
|
||||
<label class="switch">
|
||||
<input id="checkAll" asp-for="IsProgramManagerUser" type="checkbox"/>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="UserRoles" > نقش در پروگرام منیجر </label>
|
||||
<select disabled="disabled" class="form-control select-city" multiple="multiple" asp-for="UserRoles" asp-items="Model.RoleList">
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
|
||||
<span asp-validation-for="UserRoles" class="error"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@*<input type="hidden" asp-for="id" value="id"/>*@
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-success btn-rounded waves-effect waves-light m-b-5"> ثبت کاربر جدید </button>
|
||||
<button type="button" class="btn btn-default btn-rounded waves-effect waves-light m-b-5" data-dismiss="modal">بستن فرم</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#checkAll").change(function () {
|
||||
|
||||
$("#hiddenRoleIds").empty();
|
||||
|
||||
if ($(this).is(":checked")) {
|
||||
|
||||
$(".select-city").removeAttr("disabled");
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
$(".select-city").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -47,7 +47,16 @@
|
||||
transform: translateX(22px);
|
||||
}
|
||||
|
||||
select.form-control[multiple] {
|
||||
height: auto !important;
|
||||
padding: .375rem .75rem !important;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
string disable = "disabled=\"disabled\"";
|
||||
|
||||
}
|
||||
|
||||
<div class="modal-header">
|
||||
@@ -60,84 +69,151 @@
|
||||
data-callback=""
|
||||
data-action="Refresh"
|
||||
enctype="multipart/form-data">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Fullname" class="control-label">نام</label>
|
||||
<input type="text" class="form-control" asp-for="Fullname">
|
||||
<span asp-validation-for="Fullname" class="error"></span>
|
||||
@*@if (TempData["name"] != null)
|
||||
{<br /><span class="error">@TempData["name"]</span>}*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Username" class="control-label">نام کاربری</label>
|
||||
<input type="text" class="form-control" asp-for="Username">
|
||||
<span asp-validation-for="Username" class="error"></span>
|
||||
@*@if (TempData["family"] != null)
|
||||
{<br /><span class="error">@TempData["family"]</span>}*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="RoleId" class="control-label">نقش </label>
|
||||
<select class="form-control" asp-for="RoleId" asp-items='new SelectList(Model.Roles, "Id", "Name")'>
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
|
||||
<span asp-validation-for="RoleId" class="error"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Mobile" class="control-label">شماره تماس</label>
|
||||
<input type="text" class="form-control" asp-for="Mobile">
|
||||
<span asp-validation-for="Mobile" class="error"></span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProfilePhoto" class="control-label"> عکس پروفایل</label>
|
||||
<input type="file" class="form-control" asp-for="ProfilePhoto" accept="image/*">
|
||||
<span asp-validation-for="ProfilePhoto" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div>
|
||||
<span>آیا کاربر در پروگرام منیجر هم فعالیت میکند؟</span>
|
||||
<span> </span>
|
||||
<label class="switch">
|
||||
<input id="checkAll" asp-for="IsProgramManagerUser" type="checkbox" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Fullname" class="control-label">نام</label>
|
||||
<input type="text" class="form-control" asp-for="Fullname">
|
||||
<span asp-validation-for="Fullname" class="error"></span>
|
||||
@*@if (TempData["name"] != null)
|
||||
{<br /><span class="error">@TempData["name"]</span>}*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Username" class="control-label">نام کاربری</label>
|
||||
<input type="text" class="form-control" asp-for="Username">
|
||||
<span asp-validation-for="Username" class="error"></span>
|
||||
@*@if (TempData["family"] != null)
|
||||
{<br /><span class="error">@TempData["family"]</span>}*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" value="@Model.Id"/>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="RoleId" class="control-label">نقش </label>
|
||||
<select class="form-control" asp-for="RoleId" asp-items='new SelectList(Model.Roles, "Id", "Name")'>
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
|
||||
<div class="modal-footer">
|
||||
<span asp-validation-for="RoleId" class="error"></span>
|
||||
|
||||
<button type="submit" class="btn btn-success btn-rounded waves-effect waves-light m-b-5"> ثبت تغییرات </button>
|
||||
<button type="button" class="btn btn-default btn-rounded waves-effect waves-light m-b-5" data-dismiss="modal">بستن فرم</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Mobile" class="control-label">شماره تماس</label>
|
||||
<input type="text" class="form-control" asp-for="Mobile">
|
||||
<span asp-validation-for="Mobile" class="error"></span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProfilePhoto" class="control-label"> عکس پروفایل</label>
|
||||
<input type="file" class="form-control" asp-for="ProfilePhoto" accept="image/*">
|
||||
<span asp-validation-for="ProfilePhoto" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="row"></div>
|
||||
<div class="form-group" style="margin: 29px 7px 0px;">
|
||||
<span> فعالیت کاربر در پروگرام منیجر </span>
|
||||
<span> </span>
|
||||
<label class="switch">
|
||||
<input id="editcheckAll" asp-for="IsProgramManagerUser" type="checkbox"/>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
|
||||
<label asp-for="UserRoles"> نقش در پروگرام منیجر </label>
|
||||
@if (Model.IsProgramManagerUser)
|
||||
{
|
||||
<select class="form-control select-city editSelect" multiple="multiple" asp-for="UserRoles" asp-items="Model.RoleList">
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
}
|
||||
else
|
||||
{
|
||||
<select disabled="disabled" class="form-control select-city editSelect" multiple="multiple" asp-for="UserRoles" asp-items="Model.RoleList">
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
}
|
||||
|
||||
|
||||
<span asp-validation-for="UserRoles" class="error"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" value="@Model.Id"/>
|
||||
|
||||
<div id="edithiddenRoleIds"></div>
|
||||
<div class="modal-footer">
|
||||
|
||||
<button type="submit" class="btn btn-success btn-rounded waves-effect waves-light m-b-5"> ثبت تغییرات </button>
|
||||
<button type="button" class="btn btn-default btn-rounded waves-effect waves-light m-b-5" data-dismiss="modal">بستن فرم</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#editcheckAll").change(function () {
|
||||
var userRole= @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.UserRoles));
|
||||
|
||||
|
||||
|
||||
|
||||
$("#edithiddenRoleIds").empty();
|
||||
|
||||
if ($(this).is(":checked")) {
|
||||
|
||||
$(".editSelect").removeAttr("disabled");
|
||||
|
||||
} else {
|
||||
|
||||
userRole.forEach(record => {
|
||||
|
||||
$("#edithiddenRoleIds").append(
|
||||
`<input type="hidden" name="UserRoles" value="${record}" />`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(".editSelect").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -553,6 +553,16 @@
|
||||
<script src="~/adminTheme/assets/datatables/jquery.dataTables.min.js"></script>
|
||||
<script src="~/adminTheme/assets/datatables/dataTables.bootstrap.js"></script>
|
||||
<script src="~/js/signalr/dist/browser/signalr.js"></script>
|
||||
<script src="~/lib/select2/js/select2.js"></script>
|
||||
<script src="~/lib/select2/js/i18n/fa.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$(".select-city").select2({
|
||||
language: "fa",
|
||||
dir: "rtl"
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#datatable').dataTable({
|
||||
|
||||
@@ -56,11 +56,34 @@ public class IndexModel : PageModel
|
||||
|
||||
public IActionResult OnGetCreate()
|
||||
{
|
||||
var command = new CreateAccount
|
||||
|
||||
|
||||
var command = new CreateAccount
|
||||
{
|
||||
Roles = _roleApplication.List()
|
||||
};
|
||||
return Partial("./Create", command);
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
command.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return Partial("./Create", command);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +131,8 @@ public class IndexModel : PageModel
|
||||
// مثل قبل:
|
||||
if (result != null && result.isSuccess)
|
||||
{
|
||||
account.IsProgramManagerUser = (result.Data.accountId == account.Id);
|
||||
account.IsProgramManagerUser = (result.Data.accountId == account.Id && result.Data.isActive);
|
||||
account.UserRoles = apiResult.Result.Data.Roles;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,9 +141,29 @@ public class IndexModel : PageModel
|
||||
|
||||
|
||||
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
account.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
account.Roles = _roleApplication.List();
|
||||
return Partial("Edit", account);
|
||||
|
||||
@@ -331,15 +331,50 @@ builder.Services.AddParbad().ConfigureGateways(gateways =>
|
||||
storage.UseMemoryCache();
|
||||
});
|
||||
|
||||
#region GetHttpContext
|
||||
|
||||
var httpContextAccessor = new HttpContextAccessor();
|
||||
builder.Services.AddSingleton<IHttpContextAccessor>(httpContextAccessor);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors("AllowSpecificOrigins");
|
||||
|
||||
#region InternalProgarmManagerApi
|
||||
|
||||
var baseUrl = builder.Configuration["InternalProgramManagerApi:BaseUrl"];
|
||||
|
||||
|
||||
|
||||
// بعد از Build:
|
||||
var host = httpContextAccessor.HttpContext?.Request.Host.Host ?? "";
|
||||
|
||||
// مقداردهی BaseUrl
|
||||
string baseUrl;
|
||||
|
||||
if (host.Contains("localhost"))
|
||||
{
|
||||
baseUrl = builder.Configuration["InternalApi:Local"];
|
||||
}
|
||||
else if (host.Contains("dadmehrg.ir"))
|
||||
{
|
||||
baseUrl = builder.Configuration["InternalApi:Dadmehrg"];
|
||||
}
|
||||
else if (host.Contains("gozareshgir.ir"))
|
||||
{
|
||||
baseUrl = builder.Configuration["InternalApi:Gozareshgir"];
|
||||
}
|
||||
else
|
||||
{
|
||||
baseUrl = builder.Configuration["InternalApi:Local"]; // fallback
|
||||
}
|
||||
|
||||
// مقداردهی به کلاس Static
|
||||
InternalApiCaller.SetBaseUrl(baseUrl);
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
@@ -36,10 +36,13 @@
|
||||
"IsTestMode": false,
|
||||
"TestNumbers": []
|
||||
},
|
||||
|
||||
"InternalProgramManagerApi": {
|
||||
"BaseUrl": "https://localhost:7032"
|
||||
"InternalApi": {
|
||||
"Local": "https://localhost:7032",
|
||||
"Dadmehrg": "https://api.pm.dadmehrg.ir",
|
||||
"Gozareshgir": "https://api.pm.gozareshgir.ir"
|
||||
},
|
||||
|
||||
|
||||
"SepehrGateWayTerminalId": 99213700
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user