Merge from ProgramManagerUserAccount
This commit is contained in:
13
0_Framework/Application/SecretKeys.cs
Normal file
13
0_Framework/Application/SecretKeys.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _0_Framework.Application;
|
||||
|
||||
public static class SecretKeys
|
||||
{
|
||||
|
||||
public static string ProgramManagerInternalApi => "JOb09$Ic3NJd0siLCJtYWMiOiI2%dmODJmNDV";
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -35,4 +36,20 @@ public class CreateAccount
|
||||
public string Email { get; set; }
|
||||
public string VerifyCode { get; set; }
|
||||
public string IsActiveString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا کاربر در پروگرام منیجر فعالیت مبکند؟
|
||||
/// </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; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
public record ApiResponse
|
||||
{
|
||||
public bool isSuccess { get; set; }
|
||||
public string errorMessage { get; set; }
|
||||
|
||||
|
||||
|
||||
public ErrorType ErrorType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
|
||||
public record CreateProgramManagerRole
|
||||
{
|
||||
/// <summary>
|
||||
/// نام نقش
|
||||
/// </summary>
|
||||
public string RoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کدهای دسترسی
|
||||
/// </summary>
|
||||
public List<int> Permissions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی اکانت گزارشگیر
|
||||
/// </summary>
|
||||
public long? GozareshgirRoleId { get; set; }
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
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);
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
public enum ErrorType
|
||||
{
|
||||
None,
|
||||
BadRequest,
|
||||
NotFound,
|
||||
Unauthorized,
|
||||
Validation,
|
||||
InternalServerError
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
public class RoleResponse
|
||||
{
|
||||
public bool isSuccess { get; set; }
|
||||
public RolesData data { get; set; }
|
||||
}
|
||||
|
||||
public class RolesData
|
||||
{
|
||||
public List<RoleList> role { get; set; }
|
||||
}
|
||||
|
||||
public class RoleList
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string roleName { get; set; }
|
||||
public int gozareshgirRoleId { get; set; }
|
||||
public List<int> permissions { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
public record SingleUserResponseResult
|
||||
{
|
||||
public bool isSuccess { get; set; }
|
||||
public SingleUserData Data { get; set; }
|
||||
};
|
||||
|
||||
public record SingleUserData
|
||||
|
||||
{
|
||||
public long id { get; set; }
|
||||
/// <summary>
|
||||
/// نام و نام خانوادگی
|
||||
/// </summary>
|
||||
public string fullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربری
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مسیر عکس پروفایل
|
||||
/// </summary>
|
||||
public string profilePhotoPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره موبایل
|
||||
/// </summary>
|
||||
public string mobile { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیر فعال بودن یوزر
|
||||
/// </summary>
|
||||
public bool isActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// گذرواژه
|
||||
/// </summary>
|
||||
public string password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی اکانت کاربر در گزارشگیر
|
||||
/// </summary>
|
||||
public long? accountId { get; set; }
|
||||
|
||||
public List<long> Roles { get; set; }
|
||||
}
|
||||
@@ -9,6 +9,10 @@ namespace AccountManagement.Application.Contracts.Role
|
||||
[Required(ErrorMessage = ValidationMessages.IsRequired)]
|
||||
public string Name { get; set; }
|
||||
public List<int> Permissions { get; set; }
|
||||
/// <summary>
|
||||
/// لیست پرمیشن های پروگرام منیجر
|
||||
/// </summary>
|
||||
public List<int> PmPermissions { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,12 +19,18 @@ using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using _0_Framework.Exceptions;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using AccountManagement.Domain.SubAccountAgg;
|
||||
using AccountManagement.Domain.SubAccountPermissionSubtitle1Agg;
|
||||
using AccountManagement.Domain.SubAccountRoleAgg;
|
||||
using Company.Domain.WorkshopSubAccountAgg;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Company.Domain._common;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
|
||||
//using AccountManagement.Domain.RoleAgg;
|
||||
|
||||
@@ -39,15 +46,16 @@ 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;
|
||||
private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository;
|
||||
private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher,
|
||||
IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker, ISmsService smsService, ICameraAccountRepository cameraAccountRepository, IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository, IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository, ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository, ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository)
|
||||
public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher,
|
||||
IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker, ISmsService smsService, ICameraAccountRepository cameraAccountRepository, IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository, IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository, ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository, ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_authHelper = authHelper;
|
||||
_roleRepository = roleRepository;
|
||||
@@ -60,10 +68,11 @@ public class AccountApplication : IAccountApplication
|
||||
_subAccountRoleRepository = subAccountRoleRepository;
|
||||
_workshopSubAccountRepository = workshopSubAccountRepository;
|
||||
_accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository;
|
||||
_unitOfWork = unitOfWork;
|
||||
_fileUploader = fileUploader;
|
||||
_passwordHasher = passwordHasher;
|
||||
_accountRepository = accountRepository;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public OperationResult EditClient(EditClientAccount command)
|
||||
@@ -92,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();
|
||||
}
|
||||
@@ -133,15 +142,56 @@ public class AccountApplication : IAccountApplication
|
||||
var password = _passwordHasher.Hash(command.Password);
|
||||
var roleName = _roleRepository.GetDetails(command.RoleId);
|
||||
var path = $"profilePhotos";
|
||||
var picturePath = "";
|
||||
if (_fileUploader != null)
|
||||
{
|
||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
||||
picturePath, roleName.Name,"true","false");
|
||||
_accountRepository.Create(account);
|
||||
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();
|
||||
|
||||
if (command.IsProgramManagerUser)
|
||||
{
|
||||
var parameters = new CreateProgramManagerUser(
|
||||
command.Fullname,
|
||||
command.Username,
|
||||
password,
|
||||
command.Mobile,
|
||||
command.Email,
|
||||
account.id,
|
||||
command.UserRoles
|
||||
);
|
||||
|
||||
var url = "api/user/create";
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
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.Result.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
_accountRepository.SaveChanges();
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
@@ -155,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();
|
||||
@@ -173,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)
|
||||
@@ -194,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();
|
||||
}
|
||||
|
||||
@@ -210,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)
|
||||
@@ -245,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,
|
||||
@@ -255,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);
|
||||
|
||||
@@ -281,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);
|
||||
@@ -291,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)
|
||||
{
|
||||
@@ -356,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;
|
||||
@@ -429,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);
|
||||
@@ -443,11 +582,11 @@ public class AccountApplication : IAccountApplication
|
||||
_smsService.LoginSend(phone, r);
|
||||
|
||||
//TimeSpan delay = TimeSpan.FromSeconds(30);
|
||||
|
||||
|
||||
await _accountRepository.RemoveCode(id);
|
||||
|
||||
|
||||
return operation.Succcedded();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -498,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();
|
||||
@@ -641,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();
|
||||
@@ -815,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);
|
||||
|
||||
@@ -2,16 +2,23 @@
|
||||
using AccountManagement.Application.Contracts.Role;
|
||||
using AccountManagement.Domain.RoleAgg;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using Company.Domain._common;
|
||||
using AccountManagement.Application.Contracts.Ticket;
|
||||
|
||||
namespace AccountManagement.Application;
|
||||
|
||||
public class RoleApplication : IRoleApplication
|
||||
{
|
||||
private readonly IRoleRepository _roleRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public RoleApplication(IRoleRepository roleRepository)
|
||||
public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_roleRepository = roleRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRole command)
|
||||
@@ -19,18 +26,51 @@ public class RoleApplication : IRoleApplication
|
||||
var operation = new OperationResult();
|
||||
if (_roleRepository.Exists(x => x.Name == command.Name))
|
||||
return operation.Failed(ApplicationMessages.DuplicatedRecord);
|
||||
var permissions = new List<Permission>();
|
||||
foreach (var code in command.Permissions)
|
||||
{
|
||||
if (code > 0)
|
||||
{
|
||||
permissions.Add(new Permission(code));
|
||||
}
|
||||
}
|
||||
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
||||
var permissions = command.Permissions.Where(x => x > 0).Select(x => new Permission(x)).ToList();
|
||||
var role = new Role(command.Name, permissions);
|
||||
_unitOfWork.BeginAccountContext();
|
||||
|
||||
_roleRepository.Create(role);
|
||||
_roleRepository.SaveChanges();
|
||||
|
||||
var pmPermissions = command.PmPermissions.Where(x => x > 0).ToList();
|
||||
if (pmPermissions.Any())
|
||||
{
|
||||
var parameters = new CreateProgramManagerRole
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role";
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
@@ -47,17 +87,129 @@ public class RoleApplication : IRoleApplication
|
||||
//var permissions = new List<Permission>();
|
||||
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
||||
|
||||
var permissions = new List<Permission>();
|
||||
foreach (var code in command.Permissions)
|
||||
{
|
||||
if (code > 0)
|
||||
{
|
||||
permissions.Add(new Permission(code));
|
||||
}
|
||||
}
|
||||
var permissions = command.Permissions.Where(x => x > 0).Select(x => new Permission(x)).ToList();
|
||||
|
||||
|
||||
|
||||
_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("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
155
AccountManagement.Domain/InternalApiCaller/InternalApiCaller.cs
Normal file
155
AccountManagement.Domain/InternalApiCaller/InternalApiCaller.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace AccountManagement.Domain.InternalApiCaller;
|
||||
|
||||
public class ApiResult<T>
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public T Result { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
|
||||
public static class InternalApiCaller
|
||||
{
|
||||
private static string _baseUrl = "";
|
||||
|
||||
public static void SetBaseUrl(string baseUrl)
|
||||
{
|
||||
_baseUrl = baseUrl.TrimEnd('/'); // حذف / اضافی
|
||||
}
|
||||
/// <summary>
|
||||
///api post متد
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest"></typeparam>
|
||||
/// <typeparam name="TResponse"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="internalKey"></param>
|
||||
/// <param name="body"></param>
|
||||
/// <returns></returns>
|
||||
public static ApiResult<TResponse> PostAsync<TRequest, TResponse>(
|
||||
string url,
|
||||
string internalKey,
|
||||
TRequest body
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new HttpClient();
|
||||
|
||||
// ساخت URL نهایی
|
||||
var finalUrl = $"{_baseUrl}/{url.TrimStart('/')}";
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, finalUrl);
|
||||
|
||||
request.Headers.Add("X-INTERNAL-KEY", internalKey);
|
||||
|
||||
var json = JsonConvert.SerializeObject(body);
|
||||
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = client.SendAsync(request).GetAwaiter().GetResult();
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = false,
|
||||
Error = $"HTTP Error: {response.StatusCode}"
|
||||
};
|
||||
}
|
||||
|
||||
var text = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
var deserialized = JsonConvert.DeserializeObject<TResponse>(text);
|
||||
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = true,
|
||||
Result = deserialized
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = false,
|
||||
Error = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Api Get متد
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="internalKey"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public static ApiResult<TResponse> GetAsync<TResponse>(
|
||||
string url,
|
||||
string internalKey,
|
||||
Dictionary<string, object> parameters = null
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (parameters != null && parameters.Any())
|
||||
{
|
||||
var query = string.Join("&",
|
||||
parameters
|
||||
.Where(p => p.Value != null)
|
||||
.Select(p => $"{p.Key}={p.Value}")
|
||||
);
|
||||
|
||||
url += url.Contains("?") ? "&" + query : "?" + query;
|
||||
}
|
||||
|
||||
// ساخت URL نهایی
|
||||
var finalUrl = $"{_baseUrl}/{url.TrimStart('/')}";
|
||||
|
||||
var client = new HttpClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, finalUrl);
|
||||
|
||||
request.Headers.Add("X-INTERNAL-KEY", internalKey);
|
||||
|
||||
var response = client.SendAsync(request).GetAwaiter().GetResult();
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = false,
|
||||
Error = $"HTTP Error: {response.StatusCode}"
|
||||
};
|
||||
}
|
||||
|
||||
var text = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
var deserialized = JsonConvert.DeserializeObject<TResponse>(text);
|
||||
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = true,
|
||||
Result = deserialized
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ApiResult<TResponse>
|
||||
{
|
||||
Success = false,
|
||||
Error = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="CheckoutAgg\ValueObjects\" />
|
||||
<Folder Include="_common\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
8
Company.Domain/_common/IUnitOfWork.cs
Normal file
8
Company.Domain/_common/IUnitOfWork.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Company.Domain._common;
|
||||
|
||||
public interface IUnitOfWork
|
||||
{
|
||||
void BeginAccountContext();
|
||||
void CommitAccountContext();
|
||||
void RollbackAccountContext();
|
||||
}
|
||||
31
CompanyManagment.EFCore/_common/UnitOfWork.cs
Normal file
31
CompanyManagment.EFCore/_common/UnitOfWork.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain._common;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
|
||||
namespace CompanyManagment.EFCore._common;
|
||||
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly AccountContext _context;
|
||||
private IDbContextTransaction _transaction;
|
||||
|
||||
public UnitOfWork(AccountContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public void BeginAccountContext()
|
||||
{
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
}
|
||||
|
||||
public void CommitAccountContext()
|
||||
{
|
||||
_transaction?.Commit();
|
||||
}
|
||||
|
||||
public void RollbackAccountContext()
|
||||
{
|
||||
_transaction?.Rollback();
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,8 @@ using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
using _0_Framework.Application.FaceEmbedding;
|
||||
using _0_Framework.Infrastructure;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain._common;
|
||||
using CompanyManagment.EFCore._common;
|
||||
|
||||
namespace PersonalContractingParty.Config;
|
||||
|
||||
@@ -545,6 +547,13 @@ public class PersonalBootstrapper
|
||||
services.AddTransient<ISmsSettingsRepository, SmsSettingsRepository>();
|
||||
services.AddTransient<ISmsSettingApplication, SmsSettingApplication>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region UnitOfWork
|
||||
|
||||
services.AddTransient<IUnitOfWork, UnitOfWork>();
|
||||
|
||||
#endregion
|
||||
//=========End Of Main====================================
|
||||
|
||||
|
||||
@@ -1,6 +1,53 @@
|
||||
@model AccountManagement.Application.Contracts.Account.CreateAccount
|
||||
@{
|
||||
<style>
|
||||
/* Toggle Switch */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 46px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
transition: .3s;
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background-color: white;
|
||||
transition: .3s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #28a745; /* رنگ سبز مشابه Bootstrap */
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
transform: translateX(22px);
|
||||
}
|
||||
|
||||
</style>
|
||||
}
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
@@ -12,79 +59,134 @@
|
||||
data-callback=""
|
||||
data-action="Refresh"
|
||||
enctype="multipart/form-data">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<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)
|
||||
<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)
|
||||
</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>
|
||||
</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>
|
||||
<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>
|
||||
<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 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>
|
||||
</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="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>
|
||||
@*<input type="hidden" asp-for="id" value="id"/>*@
|
||||
</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>
|
||||
|
||||
<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="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>
|
||||
@@ -922,7 +922,117 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
||||
|
||||
<!-- مدیریت برنامه نویسان -->
|
||||
<div class="parent-check">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parent"> <input type="checkbox" value="99" class="check-btn" data-pm="" data-pm=""> <span style="bottom: 2px;position: relative"> مدیریت برنامه نویسان </span> </label>
|
||||
<!-- مدیریت پروژه -->
|
||||
<div class="child-check level2">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="991" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> مدیریت پروژه </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="99101" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ایجاد پروژه </span> </label>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ستون لیست پروژه -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9911" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون لیست پروژه ها </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99111" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99112" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات</span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99113" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش</span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99114" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف</span> </label>
|
||||
</div>
|
||||
</div>
|
||||
<!--ستون بخش اصلی -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9912" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون بخش اصلی </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99121" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99122" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99124" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99124" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
<!--ستون بخش فرعی -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9913" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون بخش اصلی </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99131" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99132" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99134" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99134" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--اجرا-->
|
||||
<div class="child-check level2">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="992" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> همه </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="9921" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> آماده اجرا </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="9922" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> در حال اجرا </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="9023" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> نیمه کاره </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="9024" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> اتمام اجرا </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
||||
<div id="hiddenInput" style="display: none">
|
||||
|
||||
</div>
|
||||
@@ -1096,22 +1206,36 @@
|
||||
</script>
|
||||
<script>
|
||||
function saveRole() {
|
||||
const checks = document.querySelectorAll("input[class='check-btn']");
|
||||
const checks = document.querySelectorAll("input.check-btn");
|
||||
|
||||
for (let i = 0; i < checks.length; i++) {
|
||||
let pmIndex = 0;
|
||||
let normalIndex = 0;
|
||||
|
||||
if (checks[i].checked) {
|
||||
$('#hiddenInput').append(
|
||||
`<input class="item1" type="hidden" value="${checks[i].value}" name="Permissions[${i}]"/>`
|
||||
);
|
||||
$("#hiddenInput").empty(); // مهم!! قبل از اضافهکردن، خالی کن
|
||||
|
||||
checks.forEach(chk => {
|
||||
|
||||
const isPm = chk.hasAttribute("data-pm");
|
||||
|
||||
if (isPm) {
|
||||
$("#hiddenInput").append(`
|
||||
<input class="item1" type="hidden"
|
||||
name="PmPermissions[${pmIndex}]"
|
||||
value="${chk.checked ? chk.value : 0}">
|
||||
`);
|
||||
pmIndex++;
|
||||
} else {
|
||||
$('#hiddenInput').append(
|
||||
`<input class="item1" type="hidden" value="${0}" name="Permissions[${i}]"/>`
|
||||
);
|
||||
$("#hiddenInput").append(`
|
||||
<input class="item1" type="hidden"
|
||||
name="Permissions[${normalIndex}]"
|
||||
value="${chk.checked ? chk.value : 0}">
|
||||
`);
|
||||
normalIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#subm').click();
|
||||
$("#subm").click();
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -1,5 +1,62 @@
|
||||
@model AccountManagement.Application.Contracts.Account.EditAccount
|
||||
@{
|
||||
<style>
|
||||
/* Toggle Switch */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 46px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
transition: .3s;
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background-color: white;
|
||||
transition: .3s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #28a745; /* رنگ سبز مشابه Bootstrap */
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
transform: translateX(22px);
|
||||
}
|
||||
|
||||
select.form-control[multiple] {
|
||||
height: auto !important;
|
||||
padding: .375rem .75rem !important;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
string disable = "disabled=\"disabled\"";
|
||||
|
||||
}
|
||||
|
||||
<div class="modal-header">
|
||||
@@ -12,74 +69,151 @@
|
||||
data-callback=""
|
||||
data-action="Refresh"
|
||||
enctype="multipart/form-data">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<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)
|
||||
<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)
|
||||
</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>
|
||||
</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>
|
||||
<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>
|
||||
<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 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>
|
||||
</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 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>
|
||||
|
||||
<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>
|
||||
<input type="hidden" asp-for="Id" value="@Model.Id"/>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="modal-footer">
|
||||
<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>
|
||||
}
|
||||
|
||||
|
||||
<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="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>
|
||||
@@ -934,6 +934,112 @@
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- مدیریت برنامه نویسان -->
|
||||
<div class="parent-check">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parent"> <input type="checkbox" value="99" class="check-btn" data-pm="" data-pm=""> <span style="bottom: 2px;position: relative"> مدیریت برنامه نویسان </span> </label>
|
||||
<!-- مدیریت پروژه -->
|
||||
<div class="child-check level2">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="991" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> مدیریت پروژه </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="99101" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ایجاد پروژه </span> </label>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ستون لیست پروژه -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9911" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون لیست پروژه ها </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99111" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99112" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات</span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99113" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش</span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99114" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف</span> </label>
|
||||
</div>
|
||||
</div>
|
||||
<!--ستون بخش اصلی -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9912" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون بخش اصلی </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99121" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99122" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99124" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99124" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
<!--ستون بخش فرعی -->
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="9913" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ستون بخش اصلی </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99131" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> تعیین کاربر </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="99132" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> توضیحات </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99134" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> ویرایش </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="99134" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> حذف </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--اجرا-->
|
||||
<div class="child-check level2">
|
||||
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
|
||||
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn" />
|
||||
</label>
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="992" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> همه </span> </label>
|
||||
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="9921" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> آماده اجرا </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="9922" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> در حال اجرا </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="9023" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> نیمه کاره </span> </label>
|
||||
</div>
|
||||
<div class="child-check level3">
|
||||
<label class="btn btn-inverse waves-effect waves-light m-b-5 children"><input type="checkbox" disabled="disabled" value="9024" class="check-btn" data-pm=""> <span style="bottom: 2px;position: relative"> اتمام اجرا </span> </label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
<div id="hiddenInput" @*style="display: none"*@>
|
||||
|
||||
@@ -1160,22 +1266,35 @@
|
||||
</script>
|
||||
<script>
|
||||
function saveRole() {
|
||||
const checks = document.querySelectorAll("input[class='check-btn']");
|
||||
const checks = document.querySelectorAll("input.check-btn");
|
||||
|
||||
for (let i = 0; i < checks.length; i++) {
|
||||
let pmIndex = 0;
|
||||
let normalIndex = 0;
|
||||
|
||||
if (checks[i].checked) {
|
||||
$('#hiddenInput').append(
|
||||
`<input class="item1" type="hidden" value="${checks[i].value}" name="Permissions[${i}]"/>`
|
||||
);
|
||||
$("#hiddenInput").empty(); // مهم!! قبل از اضافهکردن، خالی کن
|
||||
|
||||
checks.forEach(chk => {
|
||||
|
||||
const isPm = chk.hasAttribute("data-pm");
|
||||
|
||||
if (isPm) {
|
||||
$("#hiddenInput").append(`
|
||||
<input class="item1" type="hidden"
|
||||
name="PmPermissions[${pmIndex}]"
|
||||
value="${chk.checked ? chk.value : 0}">
|
||||
`);
|
||||
pmIndex++;
|
||||
} else {
|
||||
$('#hiddenInput').append(
|
||||
`<input class="item1" type="hidden" value="${0}" name="Permissions[${i}]"/>`
|
||||
);
|
||||
$("#hiddenInput").append(`
|
||||
<input class="item1" type="hidden"
|
||||
name="Permissions[${normalIndex}]"
|
||||
value="${chk.checked ? chk.value : 0}">
|
||||
`);
|
||||
normalIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#subm').click();
|
||||
$("#subm").click();
|
||||
}
|
||||
</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({
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using AccountManagement.Application.Contracts.Role;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Newtonsoft.Json;
|
||||
using ServiceHost.Hubs;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Pages.Accounts.Account;
|
||||
@@ -52,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +108,63 @@ public class IndexModel : PageModel
|
||||
|
||||
|
||||
public IActionResult OnGetEdit(long id)
|
||||
{
|
||||
{
|
||||
|
||||
var account = _accountApplication.GetDetails(id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
$"api/user/{account.Id}",
|
||||
key
|
||||
);
|
||||
|
||||
|
||||
|
||||
// حالا نتیجه دیسریال شده در apiResult.Result قرار دارد
|
||||
var result = apiResult.Result;
|
||||
|
||||
// مثل قبل:
|
||||
if (result != null && result.isSuccess)
|
||||
{
|
||||
account.IsProgramManagerUser = (result.Data.accountId == account.Id && result.Data.isActive);
|
||||
account.UserRoles = apiResult.Result.Data.Roles;
|
||||
}
|
||||
else
|
||||
{
|
||||
account.IsProgramManagerUser = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -100,7 +182,31 @@ public class IndexModel : PageModel
|
||||
var rol = new List<int>();
|
||||
foreach (var item in role.MappedPermissions) rol.Add(item.Code);
|
||||
|
||||
role.Permissions = rol;
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", role.Id }
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
role.Permissions = rol;
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Result.isSuccess && apiResult.Result.data.role.Any())
|
||||
{
|
||||
var pmPermission = apiResult.Result.data.role.FirstOrDefault()!.permissions;
|
||||
role.Permissions.AddRange(pmPermission);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Partial("EditRole", role);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Security.Claims;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using CompanyManagment.App.Contracts.Holiday;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ServiceHost.Pages
|
||||
{
|
||||
@@ -19,7 +21,19 @@ namespace ServiceHost.Pages
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
if(_authHelper.IsAuthenticated())
|
||||
//var client = new HttpClient();
|
||||
//var request = new HttpRequestMessage(HttpMethod.Get, $"https://localhost:7032/api/user/2");
|
||||
//request.Headers.Add("X-INTERNAL-KEY", "MY_SUPER_SECRET_3456");
|
||||
//var response = client.SendAsync(request).GetAwaiter().GetResult();
|
||||
//var success = response.IsSuccessStatusCode;
|
||||
//if (success)
|
||||
//{
|
||||
// var res = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
// var result = JsonConvert.DeserializeObject<SingleUserRespnsResult>(res);
|
||||
|
||||
// Console.WriteLine(result.Data.accountId + " " + result.Data.mobile);
|
||||
//}
|
||||
if (_authHelper.IsAuthenticated())
|
||||
return Redirect("/login");
|
||||
return Page();
|
||||
}
|
||||
@@ -30,4 +44,4 @@ namespace ServiceHost.Pages
|
||||
return RedirectToPage("/Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ using MongoDB.Driver;
|
||||
using Parbad.Builder;
|
||||
using Parbad.Gateway.Sepehr;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -330,11 +331,52 @@ 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
|
||||
|
||||
|
||||
|
||||
|
||||
// بعد از 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
|
||||
|
||||
//app.UseStatusCodePagesWithRedirects("/error/{0}");
|
||||
|
||||
@@ -41,11 +41,16 @@
|
||||
},
|
||||
"SmsSettings": {
|
||||
"IsTestMode": true,
|
||||
"TestNumbers": [ "09116967898"
|
||||
//, "09116067106", "09114221321"
|
||||
"TestNumbers": [
|
||||
"09116967898"
|
||||
//, "09116067106", "09114221321"
|
||||
]
|
||||
},
|
||||
"InternalProgramManagerApi": {
|
||||
"BaseUrl": "https://localhost:7032"
|
||||
},
|
||||
"SepehrGateWayTerminalId": 99213700
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,13 @@
|
||||
"IsTestMode": false,
|
||||
"TestNumbers": []
|
||||
},
|
||||
"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