Merge remote-tracking branch 'origin/Main' into Main
This commit is contained in:
@@ -32,7 +32,7 @@ public static class StaticWorkshopAccounts
|
||||
/// 392 - عمار حسن دوست
|
||||
/// 20 - سمیرا الهی نیا
|
||||
/// </summary>
|
||||
public static List<long> StaticAccountIds = [2, 3, 380, 381, 392, 20];
|
||||
public static List<long> StaticAccountIds = [2, 3, 380, 381, 392, 20, 476];
|
||||
|
||||
/// <summary>
|
||||
/// این تاریخ در جدول اکانت لفت ورک به این معنیست
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.Account;
|
||||
|
||||
public interface IAccountApplication
|
||||
{
|
||||
AccountViewModel GetAccountBy(long id);
|
||||
OperationResult Create(CreateAccount command);
|
||||
/// <summary>
|
||||
/// ایجاد کاربر گزارشگیر و پروگرام منیجر
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> Create(CreateAccount command);
|
||||
OperationResult RegisterClient(RegisterAccount command);
|
||||
OperationResult Edit(EditAccount command);
|
||||
Task<OperationResult> Edit(EditAccount command);
|
||||
OperationResult EditClient(EditClientAccount command);
|
||||
OperationResult ChangePassword(ChangePassword command);
|
||||
OperationResult Login(Login command);
|
||||
@@ -67,6 +73,13 @@ public interface IAccountApplication
|
||||
List<AccountViewModel> GetAdminAccountsNew();
|
||||
|
||||
void CameraLogin(CameraLoginRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت کاربر پروگرام منیجر با اکانت آی دی
|
||||
/// </summary>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetPmUserDto> GetPmUserByAccountId(long accountId);
|
||||
}
|
||||
|
||||
public class CameraLoginRequest
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManager;
|
||||
|
||||
public class GetPmUserDto
|
||||
{
|
||||
/// <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 long? AccountId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نقش ها
|
||||
/// </summary>
|
||||
public List<long> Roles { get; set; }
|
||||
|
||||
|
||||
public List<RoleListDto> RoleListDto { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public record RoleListDto
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
public long RoleId { get; set; }
|
||||
public List<int> Permissions { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.ProgramManager;
|
||||
|
||||
public record GetPmRolesDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی نقش
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام نقش
|
||||
/// </summary>
|
||||
public string RoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی نقش در گزارشگیر
|
||||
/// </summary>
|
||||
public long? GozareshgirRoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست کدهای دسترسی
|
||||
/// </summary>
|
||||
public List<int> Permissions { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,25 @@
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccountManagement.Application.Contracts.Role
|
||||
{
|
||||
public interface IRoleApplication
|
||||
{
|
||||
OperationResult Create(CreateRole command);
|
||||
OperationResult Edit(EditRole command);
|
||||
Task<OperationResult> Create(CreateRole command);
|
||||
Task<OperationResult> Edit(EditRole command);
|
||||
List<RoleViewModel> List();
|
||||
EditRole GetDetails(long id);
|
||||
|
||||
#region ProgramManager
|
||||
|
||||
Task<SelectList> GetPmRoleList(long? gozareshgirRoleId);
|
||||
Task<List<GetPmRolesDto>> GetPmRoleListToEdit(long? gozareshgirRoleId);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Exceptions;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||
using AccountManagement.Domain.CameraAccountAgg;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleUserAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using AccountManagement.Domain.RoleAgg;
|
||||
using AccountManagement.Domain.SubAccountAgg;
|
||||
using AccountManagement.Domain.SubAccountPermissionSubtitle1Agg;
|
||||
using AccountManagement.Domain.SubAccountRoleAgg;
|
||||
using Company.Domain._common;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using Company.Domain.WorkshopSubAccountAgg;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.JsonPatch.Operations;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application.Sms;
|
||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||
using AccountManagement.Domain.CameraAccountAgg;
|
||||
using AccountManagement.Domain.RoleAgg;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
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 System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
//using AccountManagement.Domain.RoleAgg;
|
||||
|
||||
@@ -52,10 +56,11 @@ public class AccountApplication : IAccountApplication
|
||||
private readonly ISubAccountRoleRepository _subAccountRoleRepository;
|
||||
private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository;
|
||||
private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository;
|
||||
private readonly IPmUserRepository _pmUserRepository;
|
||||
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, IUnitOfWork unitOfWork)
|
||||
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, IPmUserRepository pmUserRepository)
|
||||
{
|
||||
_authHelper = authHelper;
|
||||
_roleRepository = roleRepository;
|
||||
@@ -69,6 +74,7 @@ public class AccountApplication : IAccountApplication
|
||||
_workshopSubAccountRepository = workshopSubAccountRepository;
|
||||
_accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository;
|
||||
_unitOfWork = unitOfWork;
|
||||
_pmUserRepository = pmUserRepository;
|
||||
_fileUploader = fileUploader;
|
||||
_passwordHasher = passwordHasher;
|
||||
_accountRepository = accountRepository;
|
||||
@@ -132,7 +138,7 @@ public class AccountApplication : IAccountApplication
|
||||
};
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateAccount command)
|
||||
public async Task<OperationResult> Create(CreateAccount command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
|
||||
@@ -159,36 +165,61 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام و خانوادگی تکراری است");
|
||||
}
|
||||
|
||||
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام کاربری تکراری است");
|
||||
}
|
||||
|
||||
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
var create = new PmUser(command.Fullname, command.Username, command.Password, command.Mobile,
|
||||
null, account.id, userRoles);
|
||||
await _pmUserRepository.CreateAsync(create);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ایجاد کاربر پروگرام منیجر");
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Result.errorMessage);
|
||||
}
|
||||
//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);
|
||||
//}
|
||||
}
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
@@ -230,7 +261,7 @@ public class AccountApplication : IAccountApplication
|
||||
return opreation.Succcedded(register.id, message: "ثبت نام شما با موفقیت انجام شد");
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditAccount command)
|
||||
public async Task<OperationResult> Edit(EditAccount command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var account = _accountRepository.Get(command.Id);
|
||||
@@ -249,47 +280,62 @@ public class AccountApplication : IAccountApplication
|
||||
_accountRepository.SaveChanges();
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
$"api/user/{account.id}",
|
||||
key
|
||||
);
|
||||
//var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
// $"api/user/{account.id}",
|
||||
// key
|
||||
//);
|
||||
var userResult = _pmUserRepository.GetByPmUsertoEditbyAccountId(account.id).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
|
||||
|
||||
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده
|
||||
if (apiResult.Success && apiResult.Result.Data.accountId == account.id)
|
||||
if (userResult != null)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
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)
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
userResult.Edit(command.Fullname, command.Username, command.Mobile, userRoles, command.IsProgramManagerUser);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
|
||||
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.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
}
|
||||
//if (!response.Success)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
|
||||
//}
|
||||
|
||||
//if (!response.Result.isSuccess)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Error);
|
||||
//}
|
||||
|
||||
}
|
||||
else //اگر کاربر قبلا ایجاد نشده
|
||||
@@ -298,38 +344,77 @@ public class AccountApplication : IAccountApplication
|
||||
if (command.IsProgramManagerUser)
|
||||
{
|
||||
if (!command.UserRoles.Any())
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
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)
|
||||
if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Error);
|
||||
return operation.Failed("نام و خانوادگی تکراری است");
|
||||
}
|
||||
|
||||
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("نام کاربری تکراری است");
|
||||
}
|
||||
|
||||
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
|
||||
var create = new PmUser(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||
null, account.id, userRoles);
|
||||
await _pmUserRepository.CreateAsync(create);
|
||||
await _pmUserRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
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);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -968,4 +1053,9 @@ public class AccountApplication : IAccountApplication
|
||||
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
}
|
||||
|
||||
public async Task<GetPmUserDto> GetPmUserByAccountId(long accountId)
|
||||
{
|
||||
return await _pmUserRepository.GetPmUserByAccountId(accountId);
|
||||
}
|
||||
}
|
||||
@@ -3,25 +3,36 @@ using AccountManagement.Application.Contracts.Role;
|
||||
using AccountManagement.Domain.RoleAgg;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||
using AccountManagement.Domain.InternalApiCaller;
|
||||
using Company.Domain._common;
|
||||
using AccountManagement.Application.Contracts.Ticket;
|
||||
using AccountManagement.Domain.PmDomains.PmPermissionAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Role = AccountManagement.Domain.RoleAgg.Role;
|
||||
|
||||
namespace AccountManagement.Application;
|
||||
|
||||
public class RoleApplication : IRoleApplication
|
||||
{
|
||||
private readonly IRoleRepository _roleRepository;
|
||||
private readonly IPmRoleRepository _pmRoleRepository;
|
||||
private readonly IPmUserRepository _pmUserRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork)
|
||||
public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork, IPmRoleRepository pmRoleRepository, IPmUserRepository pmUserRepository)
|
||||
{
|
||||
_roleRepository = roleRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
_pmRoleRepository = pmRoleRepository;
|
||||
_pmUserRepository = pmUserRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRole command)
|
||||
public async Task<OperationResult> Create(CreateRole command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
if (_roleRepository.Exists(x => x.Name == command.Name))
|
||||
@@ -36,36 +47,49 @@ public class RoleApplication : IRoleApplication
|
||||
var pmPermissions = command.PmPermissions.Where(x => x > 0).ToList();
|
||||
if (pmPermissions.Any())
|
||||
{
|
||||
var parameters = new CreateProgramManagerRole
|
||||
try
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
var pmPermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
|
||||
var pmRole = new PmRole(command.Name, role.id, pmPermissionsData);
|
||||
await _pmRoleRepository.CreateAsync(pmRole);
|
||||
await _pmRoleRepository.SaveChangesAsync();
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role";
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||
url,
|
||||
key,
|
||||
parameters
|
||||
);
|
||||
|
||||
|
||||
if (!response.Success)
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد"+ response.Error);
|
||||
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||
}
|
||||
|
||||
if (!response.Result.isSuccess)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed(response.Result.errorMessage);
|
||||
}
|
||||
//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);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +99,7 @@ public class RoleApplication : IRoleApplication
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditRole command)
|
||||
public async Task<OperationResult> Edit(EditRole command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var role = _roleRepository.Get(command.Id);
|
||||
@@ -90,7 +114,7 @@ public class RoleApplication : IRoleApplication
|
||||
|
||||
var permissions = command.Permissions.Where(x => x > 0).Select(x => new Permission(x)).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
_unitOfWork.BeginAccountContext();
|
||||
role.Edit(command.Name, permissions);
|
||||
@@ -100,111 +124,120 @@ public class RoleApplication : IRoleApplication
|
||||
|
||||
|
||||
//یافتن نقش در پروگرام منیجر
|
||||
var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
//var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
// { "GozareshgirRoleId", command.Id}
|
||||
// }
|
||||
//);
|
||||
|
||||
|
||||
var pmRoleResult = await _pmRoleRepository.GetPmRoleToEdit(command.Id);
|
||||
|
||||
|
||||
//اگر این نقش در پروگرام منیجر وجود داشت ویرایش کن
|
||||
if (pmRoleResult != null)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", command.Id}
|
||||
var pmpermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
|
||||
pmRoleResult.Edit(command.Name, pmpermissionsData);
|
||||
await _pmRoleRepository.SaveChangesAsync();
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
//var parameters = new CreateProgramManagerRole
|
||||
//{
|
||||
// RoleName = command.Name,
|
||||
// Permissions = pmPermissions,
|
||||
// GozareshgirRoleId = role.id
|
||||
|
||||
if (apiResult.Success)
|
||||
{
|
||||
|
||||
|
||||
//اگر این نقش در پروگرام منیجر وجود داشت ویرایش کن
|
||||
if (apiResult.Result.data.role.Any())
|
||||
{
|
||||
var parameters = new CreateProgramManagerRole
|
||||
{
|
||||
RoleName = command.Name,
|
||||
Permissions = pmPermissions,
|
||||
GozareshgirRoleId = role.id
|
||||
|
||||
};
|
||||
|
||||
var url = "api/role/edit";
|
||||
//};
|
||||
//var url = "api/role/edit";
|
||||
//var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||
// url,
|
||||
// key,
|
||||
// parameters
|
||||
//);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if (!response.Success)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
//}
|
||||
|
||||
//if (!response.Result.isSuccess)
|
||||
//{
|
||||
// _unitOfWork.RollbackAccountContext();
|
||||
// return operation.Failed(response.Result.errorMessage);
|
||||
//}
|
||||
}
|
||||
else
|
||||
else //اگر نقش در پروگرام منیجر وجود نداشت
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||
|
||||
//اگر تیک پرمیشن های پروگرام منیجر زده شده
|
||||
//این نقش را سمت پروگرام منیجر بساز
|
||||
if (pmPermissions.Any())
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var pmPermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
|
||||
var pmRole = new PmRole(command.Name, command.Id, pmPermissionsData);
|
||||
await _pmRoleRepository.CreateAsync(pmRole);
|
||||
await _pmRoleRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
_unitOfWork.RollbackAccountContext();
|
||||
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||
}
|
||||
|
||||
//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);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
_unitOfWork.CommitAccountContext();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
@@ -217,4 +250,23 @@ public class RoleApplication : IRoleApplication
|
||||
{
|
||||
return _roleRepository.List();
|
||||
}
|
||||
|
||||
|
||||
public async Task<SelectList> GetPmRoleList(long? gozareshgirRoleId)
|
||||
{
|
||||
var rolse = await _pmRoleRepository.GetPmRoleList(gozareshgirRoleId);
|
||||
return new SelectList(rolse, "Id", "RoleName");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<GetPmRolesDto>> GetPmRoleListToEdit(long? gozareshgirRoleId)
|
||||
{
|
||||
return await _pmRoleRepository.GetPmRoleList(gozareshgirRoleId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
18
AccountManagement.Configuration/PmDbBootstrapper.cs
Normal file
18
AccountManagement.Configuration/PmDbBootstrapper.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
|
||||
using AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace AccountManagement.Configuration;
|
||||
|
||||
public class PmDbBootstrapper
|
||||
{
|
||||
public static void Configure(IServiceCollection services, string connectionString)
|
||||
{
|
||||
services.AddTransient<IPmRoleRepository, PmRoleRepository>();
|
||||
services.AddTransient<IPmUserRepository, PmUserRepository>();
|
||||
services.AddDbContext<PmDbContext>(x => x.UseSqlServer(connectionString));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmPermissionAgg;
|
||||
|
||||
public class PmPermission
|
||||
{
|
||||
public long Id { get; private set; }
|
||||
public int Code { get; private set; }
|
||||
public PmRole Role { get; private set; }
|
||||
|
||||
public PmPermission(int code)
|
||||
{
|
||||
Code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using _0_Framework.Domain;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
|
||||
public interface IPmRoleRepository :IRepository<long, PmRole>
|
||||
{
|
||||
Task<List<GetPmRolesDto>> GetPmRoleList(long? gozareshgirRoleId);
|
||||
|
||||
Task<PmRole?> GetPmRoleToEdit(long gozareshgirRoleId);
|
||||
|
||||
}
|
||||
|
||||
46
AccountManagement.Domain/PmDomains/PmRoleAgg/PmRole.cs
Normal file
46
AccountManagement.Domain/PmDomains/PmRoleAgg/PmRole.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Domain.PmDomains.PmPermissionAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
|
||||
public class PmRole : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// نام نقش
|
||||
/// </summary>
|
||||
public string RoleName { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست پرمیشن کد ها
|
||||
/// </summary>
|
||||
public List<PmPermission> PmPermission { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی نقش در گزارشگیر
|
||||
/// </summary>
|
||||
public long? GozareshgirRoleId { get; private set; }
|
||||
|
||||
|
||||
protected PmRole()
|
||||
{
|
||||
}
|
||||
|
||||
public PmRole(string roleName,long? gozareshgirRolId, List<PmPermission> permissions)
|
||||
{
|
||||
RoleName = roleName;
|
||||
PmPermission = permissions;
|
||||
GozareshgirRoleId = gozareshgirRolId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Edit(string roleName, List<PmPermission> permissions)
|
||||
{
|
||||
RoleName = roleName;
|
||||
PmPermission = permissions;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmRoleUserAgg;
|
||||
|
||||
public class PmRoleUser
|
||||
{
|
||||
public PmRoleUser(long roleId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
}
|
||||
|
||||
public long Id { get; private set; }
|
||||
public long RoleId { get; private set; }
|
||||
|
||||
|
||||
public PmUser User { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
public interface IPmUserRepository : IRepository<long, PmUser>
|
||||
{
|
||||
/// <summary>
|
||||
/// دریافت کاربر پروگرام منیجر جهتد ویرایش
|
||||
/// </summary>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<PmUser?> GetByPmUsertoEditbyAccountId(long accountId);
|
||||
/// <summary>
|
||||
/// دریافت کرابر پروگرام منیجر با اکانت آی دی در گزارشگیر
|
||||
/// </summary>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetPmUserDto> GetPmUserByAccountId(long accountId);
|
||||
}
|
||||
127
AccountManagement.Domain/PmDomains/PmUserAgg/PmUser.cs
Normal file
127
AccountManagement.Domain/PmDomains/PmUserAgg/PmUser.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleUserAgg;
|
||||
|
||||
|
||||
namespace AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
|
||||
/// <summary>
|
||||
/// کاربر
|
||||
/// </summary>
|
||||
public class PmUser : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ایجاد
|
||||
/// </summary>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="roles"></param>
|
||||
public PmUser(string fullName, string userName, string password, string mobile, string email, long? accountId, List<PmRoleUser> roles)
|
||||
{
|
||||
FullName = fullName;
|
||||
UserName = userName;
|
||||
Password = password;
|
||||
Mobile = mobile;
|
||||
Email = email;
|
||||
IsActive = true;
|
||||
AccountId = accountId;
|
||||
RoleUser = roles;
|
||||
}
|
||||
|
||||
protected PmUser()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// نام و نام خانوادگی
|
||||
/// </summary>
|
||||
public string FullName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربری
|
||||
/// </summary>
|
||||
public string UserName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// گذرواژه
|
||||
/// </summary>
|
||||
public string Password { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// مسیر عکس پروفایل
|
||||
/// </summary>
|
||||
public string ProfilePhotoPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره موبایل
|
||||
/// </summary>
|
||||
public string Mobile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ایمیل
|
||||
/// </summary>
|
||||
public string Email { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیر فعال بودن یوزر
|
||||
/// </summary>
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// کد یکبارمصرف ورود
|
||||
/// </summary>
|
||||
public string VerifyCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی کاربر در گزارشگیر
|
||||
/// </summary>
|
||||
public long? AccountId { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست پرمیشن کد ها
|
||||
/// </summary>
|
||||
public List<PmRoleUser> RoleUser { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آپدیت کاربر
|
||||
/// </summary>
|
||||
/// <param name="fullName"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="roles"></param>
|
||||
/// <param name="isActive"></param>
|
||||
public void Edit(string fullName, string userName, string mobile, List<PmRoleUser> roles, bool isActive)
|
||||
{
|
||||
FullName = fullName;
|
||||
UserName = userName;
|
||||
Mobile = mobile;
|
||||
RoleUser = roles;
|
||||
IsActive = isActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// غیرفعال سازی
|
||||
/// </summary>
|
||||
public void DeActive()
|
||||
{
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// فعال سازی
|
||||
/// </summary>
|
||||
public void ReActive()
|
||||
{
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
|
||||
|
||||
public class PmRoleMapping : IEntityTypeConfiguration<PmRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PmRole> builder)
|
||||
{
|
||||
builder.ToTable("PmRoles", t => t.ExcludeFromMigrations());
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.RoleName).HasMaxLength(100).IsRequired();
|
||||
|
||||
builder.OwnsMany(x => x.PmPermission, navigationBuilder =>
|
||||
{
|
||||
navigationBuilder.HasKey(x => x.Id);
|
||||
navigationBuilder.ToTable("PmRolePermissions", t => t.ExcludeFromMigrations());
|
||||
|
||||
navigationBuilder.WithOwner(x => x.Role);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
|
||||
|
||||
public class PmUserMapping :IEntityTypeConfiguration<PmUser>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PmUser> builder)
|
||||
{
|
||||
builder.ToTable("Users");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.FullName).HasMaxLength(100).IsRequired();
|
||||
builder.Property(x => x.UserName).HasMaxLength(100).IsRequired();
|
||||
builder.Property(x => x.Password).HasMaxLength(1000).IsRequired();
|
||||
builder.Property(x => x.ProfilePhotoPath).HasMaxLength(500).IsRequired(false);
|
||||
builder.Property(x => x.Mobile).HasMaxLength(20).IsRequired();
|
||||
builder.Property(x => x.Email).HasMaxLength(150).IsRequired(false); ;
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(10).IsRequired(false);
|
||||
builder.OwnsMany(x => x.RoleUser, navigationBuilder =>
|
||||
{
|
||||
navigationBuilder.HasKey(x => x.Id);
|
||||
navigationBuilder.ToTable("RoleUsers");
|
||||
navigationBuilder.WithOwner(x => x.User);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using AccountMangement.Infrastructure.EFCore.Mappings;
|
||||
using AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.PmDbConetxt;
|
||||
|
||||
public class PmDbContext : DbContext
|
||||
{
|
||||
public PmDbContext(DbContextOptions<PmDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
public DbSet<PmUser> Users { get; set; } = null!;
|
||||
public DbSet<PmRole> PmRoles { get; set; } = null!;
|
||||
|
||||
|
||||
public PmDbContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
var assembly = typeof(PmUserMapping).Assembly;
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
|
||||
//SubAccountPermissionSeeder.Seed(modelBuilder);
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using AccountManagement.Domain.PmDomains.PmRoleAgg;
|
||||
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
|
||||
|
||||
public class PmRoleRepository : RepositoryBase<long, PmRole>, IPmRoleRepository
|
||||
{
|
||||
private readonly PmDbContext _pmDbContext;
|
||||
public PmRoleRepository(PmDbContext context) : base(context)
|
||||
{
|
||||
_pmDbContext = context;
|
||||
}
|
||||
|
||||
public async Task<List<GetPmRolesDto>> GetPmRoleList(long? gozareshgirRoleId)
|
||||
{
|
||||
var query = _pmDbContext.PmRoles.AsQueryable();
|
||||
if (gozareshgirRoleId != null && gozareshgirRoleId > 0)
|
||||
query = query.Where(x => x.GozareshgirRoleId == gozareshgirRoleId);
|
||||
var res = await query
|
||||
.Select(p => new GetPmRolesDto()
|
||||
{
|
||||
Id = p.id,
|
||||
RoleName = p.RoleName,
|
||||
GozareshgirRoleId = p.GozareshgirRoleId,
|
||||
Permissions = p.PmPermission.Select(x => x.Code).ToList()
|
||||
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<PmRole?> GetPmRoleToEdit(long gozareshgirRoleId)
|
||||
{
|
||||
return await _pmDbContext.PmRoles.FirstOrDefaultAsync(x => x.GozareshgirRoleId == gozareshgirRoleId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountManagement.Application.Contracts.ProgramManager;
|
||||
using AccountManagement.Domain.PmDomains.PmUserAgg;
|
||||
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
|
||||
|
||||
public class PmUserRepository :RepositoryBase<long, PmUser>, IPmUserRepository
|
||||
{
|
||||
private readonly PmDbContext _pmDbContext;
|
||||
public PmUserRepository(PmDbContext context, PmDbContext pmDbContext) : base(context)
|
||||
{
|
||||
_pmDbContext = pmDbContext;
|
||||
}
|
||||
public async Task<PmUser?> GetByPmUsertoEditbyAccountId(long accountId)
|
||||
{
|
||||
return await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId);
|
||||
}
|
||||
|
||||
public async Task<GetPmUserDto> GetPmUserByAccountId(long accountId)
|
||||
{
|
||||
var query = await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId);
|
||||
if (query == null)
|
||||
return new GetPmUserDto();
|
||||
List<long> roles = query.RoleUser.Select(x => x.RoleId).ToList();
|
||||
return new GetPmUserDto()
|
||||
{
|
||||
FullName = query.FullName,
|
||||
UserName = query.UserName,
|
||||
ProfilePhotoPath = query.ProfilePhotoPath,
|
||||
Mobile = query.Mobile,
|
||||
IsActive = query.IsActive,
|
||||
AccountId = query.AccountId,
|
||||
Roles = roles,
|
||||
RoleListDto = await _pmDbContext.PmRoles.Where(x => roles.Contains(x.id)).Select(x => new RoleListDto()
|
||||
{
|
||||
RoleName = x.RoleName,
|
||||
RoleId = x.id,
|
||||
Permissions = x.PmPermission.Select(x => x.Code).ToList()
|
||||
}).ToListAsync(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -290,4 +290,13 @@ public class PersonalContractingParty : EntityBase
|
||||
this.Gender = gender;
|
||||
this.IsAuthenticated = true;
|
||||
}
|
||||
|
||||
public void EditLegalPartyFromInstitution(string legalPosition, string companyName,
|
||||
string registerId,string nationalId)
|
||||
{
|
||||
LegalPosition = legalPosition;
|
||||
LName = companyName;
|
||||
RegisterId = registerId;
|
||||
NationalId = nationalId;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace Company.Domain.EmployeeDocumentsAgg
|
||||
{
|
||||
WorkshopId = workshopId;
|
||||
EmployeeId = employeeId;
|
||||
Gender = gender;
|
||||
Gender = gender??string.Empty;
|
||||
}
|
||||
|
||||
private EmployeeDocuments()
|
||||
|
||||
@@ -55,8 +55,8 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
void UpdateStatusIfNeeded(long institutionContractId);
|
||||
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
|
||||
Task<InstitutionContract> GetByPublicIdAsync(Guid id);
|
||||
InstitutionContractExtensionPaymentResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractExtensionPaymentResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
|
||||
|
||||
#region Extension
|
||||
@@ -65,8 +65,9 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
Task<InstitutionContractExtensionWorkshopsResponse> GetExtensionWorkshops(InstitutionContractExtensionWorkshopsRequest request);
|
||||
Task<InstitutionContractExtensionPlanResponse> GetExtensionInstitutionPlan(InstitutionContractExtensionPlanRequest request);
|
||||
Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(InstitutionContractExtensionPaymentRequest request);
|
||||
Task<InstitutionContractExtensionPaymentResponse> SetDiscountForExtension(InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractExtensionPaymentResponse> ResetDiscountForExtension(InstitutionContractResetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> ResetDiscountForExtension(InstitutionContractResetDiscountForExtensionRequest request);
|
||||
|
||||
Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CreateInstitutionContractRequest
|
||||
/// <summary>
|
||||
/// مبلغ کل قرارداد
|
||||
/// </summary>
|
||||
public double TotalAmount { get; set; }
|
||||
public double PaymentAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا قرارداد اقساطی است؟
|
||||
|
||||
@@ -215,8 +215,8 @@ public interface IInstitutionContractApplication
|
||||
Task<OperationResult<OtpResultViewModel>> SendVerifyOtp(Guid id);
|
||||
Task<OperationResult<string>> VerifyOtpAndMakeGateway(Guid publicId, string code, string callbackUrl);
|
||||
Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId);
|
||||
InstitutionContractExtensionPaymentResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractExtensionPaymentResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
|
||||
#region Extension
|
||||
|
||||
@@ -231,9 +231,10 @@ public interface IInstitutionContractApplication
|
||||
Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(
|
||||
InstitutionContractExtensionPaymentRequest request);
|
||||
|
||||
Task<InstitutionContractExtensionPaymentResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<ActionResult<InstitutionContractExtensionPaymentResponse>> ResetDiscountForExtension(InstitutionContractResetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> ResetDiscountForExtension(
|
||||
InstitutionContractResetDiscountForExtensionRequest request);
|
||||
|
||||
|
||||
Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request);
|
||||
@@ -268,12 +269,48 @@ public interface IInstitutionContractApplication
|
||||
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountResponse
|
||||
{
|
||||
public InstitutionContractDiscountOneTimeViewModel OneTime { get; set; }
|
||||
public InstitutionContractDiscountMonthlyViewModel Monthly { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountMonthlyViewModel:InstitutionContractDiscountOneTimeViewModel
|
||||
{
|
||||
public List<MonthlyInstallment> Installments { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountOneTimeViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// مجموع مبالغ
|
||||
/// </summary>
|
||||
public string TotalAmount { get; set; }
|
||||
/// <summary>
|
||||
/// ارزش افزوده
|
||||
/// </summary>
|
||||
public string Tax { get; set; }
|
||||
/// <summary>
|
||||
/// مبلغ قابل پرداخت
|
||||
/// </summary>
|
||||
public string PaymentAmount { get; set; }
|
||||
|
||||
public string DiscountedAmount { get; set; }
|
||||
|
||||
public int DiscountPercetage { get; set; }
|
||||
|
||||
public string Obligation { get; set; }
|
||||
|
||||
public string OneMonthAmount { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractResetDiscountForCreateRequest
|
||||
{
|
||||
public int Percentage { get; set; }
|
||||
public int DiscountPercentage { get; set; }
|
||||
public double TotalAmount { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
public InstitutionContractDuration Duration { get; set; }
|
||||
public double OneMonthAmount { get; set; }
|
||||
}
|
||||
|
||||
public class GetInstitutionAmendmentVerificationDetailsViewModel
|
||||
@@ -313,6 +350,7 @@ public class InstitutionContractSetDiscountRequest
|
||||
public int DiscountPercentage { get; set; }
|
||||
public double TotalAmount { get; set; }
|
||||
public InstitutionContractDuration Duration { get; set; }
|
||||
public double OneMonthAmount { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1585,7 +1585,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
if (employee.IsAuthorized == false)
|
||||
{
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
if (apiResult.ResponseContext.Status.Code == 14)
|
||||
|
||||
if (apiResult == null)
|
||||
{
|
||||
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
|
||||
}
|
||||
if (apiResult.ResponseContext.Status.Code is 14 or 3)
|
||||
{
|
||||
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
|
||||
|
||||
@@ -1644,8 +1649,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
};
|
||||
return op.Succcedded(data);
|
||||
}
|
||||
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
if (apiResult.ResponseContext.Status.Code == 14)
|
||||
if (apiResult == null)
|
||||
{
|
||||
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
|
||||
}
|
||||
if (apiResult.ResponseContext.Status.Code is 14 or 3)
|
||||
{
|
||||
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
|
||||
|
||||
|
||||
@@ -888,6 +888,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
public void RemoveContract(long id)
|
||||
{
|
||||
_institutionContractRepository.RemoveContract(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -981,6 +982,12 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
existingContractingParty.UnAuthenticateLegalEdit(legalCommand.FName,legalCommand.LName,legalCommand.FatherName,legalCommand.IdNumber,existingContractingParty.IdNumberSeri,existingContractingParty.IdNumberSerial,
|
||||
legalCommand.BirthDateFa,legalCommand.Gender,legalCommand.PhoneNumber);
|
||||
}
|
||||
|
||||
if (existingContractingParty != null)
|
||||
{
|
||||
existingContractingParty.EditLegalPartyFromInstitution(command.LegalParty.Position,command.LegalParty.CompanyName,
|
||||
command.LegalParty.RegisterId,command.LegalParty.NationalId);
|
||||
}
|
||||
}
|
||||
else if (command.ContractingPartyLegalType == LegalType.Real)
|
||||
{
|
||||
@@ -1081,7 +1088,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
contractStartGr,
|
||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), command.OneMonthAmount,
|
||||
command.DailyCompensation,
|
||||
command.Obligation, command.TotalAmount, 0,
|
||||
command.Obligation, command.PaymentAmount, 0,
|
||||
command.Workshops.Count.ToString(),
|
||||
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
|
||||
"NotOfficial", "JobRelation", hasValueAddedTax,
|
||||
@@ -1104,7 +1111,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
if (command.IsInstallment)
|
||||
{
|
||||
var installments =
|
||||
CalculateInstallment(command.TotalAmount, (int)command.Duration, command.ContractStartFa, true);
|
||||
CalculateInstallment(command.PaymentAmount, (int)command.Duration, command.ContractStartFa, true);
|
||||
|
||||
|
||||
// دریافت مبلغ اولین قسط
|
||||
@@ -1423,12 +1430,12 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return res;
|
||||
}
|
||||
|
||||
public InstitutionContractExtensionPaymentResponse CalculateDiscount(InstitutionContractSetDiscountRequest request)
|
||||
public InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request)
|
||||
{
|
||||
return _institutionContractRepository.CalculateDiscount(request);
|
||||
}
|
||||
|
||||
public InstitutionContractExtensionPaymentResponse ResetDiscountCreate(
|
||||
public InstitutionContractDiscountResponse ResetDiscountCreate(
|
||||
InstitutionContractResetDiscountForCreateRequest request)
|
||||
{
|
||||
return _institutionContractRepository.ResetDiscountCreate(request);
|
||||
@@ -1457,13 +1464,14 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return await _institutionContractRepository.GetExtensionPaymentMethod(request);
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionPaymentResponse> SetDiscountForExtension(
|
||||
public async Task<InstitutionContractDiscountResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.SetDiscountForExtension(request);
|
||||
}
|
||||
|
||||
public async Task<ActionResult<InstitutionContractExtensionPaymentResponse>> ResetDiscountForExtension(InstitutionContractResetDiscountForExtensionRequest request)
|
||||
public async Task<InstitutionContractDiscountResponse> ResetDiscountForExtension(
|
||||
InstitutionContractResetDiscountForExtensionRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.ResetDiscountForExtension(request);
|
||||
}
|
||||
|
||||
@@ -290,8 +290,34 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
|
||||
|
||||
//get rollCallEmployee associated with those leftworks which have a higher end date than leftworkDate
|
||||
|
||||
var rollCallsEmployee = _rollCallEmployeeRepository.GetBy(employeeId, workshopId);
|
||||
|
||||
if (rollCallsEmployee != null)
|
||||
{
|
||||
var status = rollCallsEmployee.EmployeesStatus.OrderByDescending(z => z.StartDate)
|
||||
.FirstOrDefault(rollCallEmployeeStatus => rollCallEmployeeStatus.StartDate.Date < maxLeftWork.LeftWorkDateGr
|
||||
&& rollCallEmployeeStatus.EndDate.Date >
|
||||
maxLeftWork.LeftWorkDateGr);
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
var adjust = new AdjustRollCallEmployeesWithEmployeeLeftWork()
|
||||
{
|
||||
LeaveDate = maxLeftWork.LeftWorkDateGr,
|
||||
RollCallStatusId = status.id
|
||||
};
|
||||
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates([adjust]);
|
||||
}
|
||||
|
||||
var rollCallEmployeeStatusList = rollCallsEmployee.EmployeesStatus
|
||||
.Where(x => x.StartDate >= maxLeftWork.LeftWorkDateGr).ToList();
|
||||
if (rollCallEmployeeStatusList.Any())
|
||||
{
|
||||
_rollCallEmployeeStatusRepository.RemoveRange(rollCallEmployeeStatusList);
|
||||
_rollCallEmployeeStatusRepository.SaveChanges();
|
||||
}
|
||||
}
|
||||
// var joinedList = rollCallsEmployee.Join(leftWorks, x => x.WorkshopId, y => y.WorkshopId, (x, y) => new
|
||||
// {
|
||||
// x.WorkshopId,
|
||||
@@ -301,27 +327,6 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
// });
|
||||
|
||||
|
||||
var status = rollCallsEmployee.EmployeesStatus.OrderByDescending(z => z.StartDate)
|
||||
.FirstOrDefault(rollCallEmployeeStatus => rollCallEmployeeStatus.StartDate.Date < maxLeftWork.LeftWorkDateGr
|
||||
&& rollCallEmployeeStatus.EndDate.Date >
|
||||
maxLeftWork.LeftWorkDateGr);
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
var adjust = new AdjustRollCallEmployeesWithEmployeeLeftWork()
|
||||
{
|
||||
LeaveDate = maxLeftWork.LeftWorkDateGr,
|
||||
RollCallStatusId = status.id
|
||||
};
|
||||
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates([adjust]);
|
||||
}
|
||||
|
||||
var rollCallEmployeeStatusList = rollCallsEmployee.EmployeesStatus
|
||||
.Where(x => x.StartDate >= maxLeftWork.LeftWorkDateGr).ToList();
|
||||
if (rollCallEmployeeStatusList.Any())
|
||||
{
|
||||
_rollCallEmployeeStatusRepository.RemoveRange(rollCallEmployeeStatusList);
|
||||
_rollCallEmployeeStatusRepository.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||
}
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate >= y.StartDateGr && x.EndDate <= y.EndDateGr)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
@@ -486,7 +486,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate >= y.StartDateGr && x.EndDate <= y.EndDateGr)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date
|
||||
&& x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
@@ -630,7 +631,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||
}
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate >= y.StartDateGr && x.EndDate <= y.EndDateGr)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
@@ -662,7 +663,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
&& (y.StartDate.Value.Date <= x.ContractEndGr.Date))))
|
||||
return operation.Failed("برای بازه های وارد شده فیش حقوقی ثبت شده است");
|
||||
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate >= y.StartDateGr && x.EndDate <= y.EndDateGr)))
|
||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
var currentDayRollCall = employeeRollCalls.FirstOrDefault(x => x.EndDate == null);
|
||||
|
||||
@@ -240,6 +240,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
result.IdNumberSerial = createTemp.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.NationalCode = createTemp.NationalCode;
|
||||
result.Phone = createTemp.Phone;
|
||||
result.IdNumberSeri = createTemp.IdNumberSeri;
|
||||
|
||||
|
||||
return op.Succcedded(result);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4723,6 +4723,8 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
#endregion
|
||||
|
||||
#region KebabMahdiAbsentsCaclculation
|
||||
|
||||
|
||||
|
||||
var rollCallDays = groupedRollCall.Count > mandatoryDays ? mandatoryDays : groupedRollCall.Count;
|
||||
|
||||
@@ -5108,6 +5110,45 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region اگر که پرسنل در روز های جمعه یا پنجشنبه غیبت داشت یک روز به غیبت اضافه شود
|
||||
//این منطق زمانی برقرار هست که مرخصی در اون روز نداشته باشه
|
||||
|
||||
// ساخت لیست روزهای بین شروع و پایان قرارداد
|
||||
var contractDaysList = Enumerable.Range(0, (contractEnd - contractStart).Days + 1)
|
||||
.Select(offset => contractStart.AddDays(offset))
|
||||
.ToList();
|
||||
|
||||
// کم کردن روزهایی که حضور دارند
|
||||
var absentDaysList = contractDaysList
|
||||
.Where(date => !groupedRollCall.Any(g => g.ShiftDate.Date == date.Date))
|
||||
.ToList();
|
||||
|
||||
var absentFridaysOrThursdays = absentDaysList
|
||||
.Where(date => date.DayOfWeek is DayOfWeek.Friday or DayOfWeek.Thursday)
|
||||
.ToList();
|
||||
|
||||
var leaveList = _context.LeaveList
|
||||
.Where(x => x.EmployeeId == employeeId
|
||||
&& x.WorkshopId == workshopId
|
||||
&& x.IsAccepted == true
|
||||
&& x.StartLeave <= contractEnd
|
||||
&& x.EndLeave >= contractStart
|
||||
&& x.LeaveType == "استحقاقی"
|
||||
&& x.PaidLeaveType =="روزانه")
|
||||
.Select(x => new { x.StartLeave, x.EndLeave })
|
||||
.ToList();
|
||||
|
||||
// بررسی کدام روزهای غایب جمعه/پنجشنبه در بازه مرخصی قرار ندارند
|
||||
var absentFridaysOrThursdaysWithoutLeave = absentFridaysOrThursdays
|
||||
.Where(date => !leaveList.Any(leave => date.Date >= leave.StartLeave.Date && date.Date <= leave.EndLeave.Date))
|
||||
.ToList();
|
||||
|
||||
// تعداد روزهای غایب جمعه/پنجشنبه بدون مرخصی
|
||||
int absentFridaysOrThursdaysWithoutLeaveCount = absentFridaysOrThursdaysWithoutLeave.Count;
|
||||
|
||||
absentsDeductionAmount += absentFridaysOrThursdaysWithoutLeaveCount * dailyWage;
|
||||
#endregion
|
||||
|
||||
|
||||
return new CustomizeCheckoutMandatoryViewModel
|
||||
|
||||
@@ -70,13 +70,23 @@ public class UidService : IUidService
|
||||
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
|
||||
if (responseResult.BasicInformation != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(responseResult.BasicInformation.FirstName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
|
||||
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
|
||||
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// ذخیره اطلاعات در جدول AuthorizedPerson
|
||||
await SaveAuthorizedPersonData(responseResult, nationalCode, birthDate);
|
||||
|
||||
@@ -459,14 +459,14 @@ public class institutionContractController : AdminBaseController
|
||||
return operationResult;
|
||||
}
|
||||
[HttpPost("create/set-discount")]
|
||||
public ActionResult<InstitutionContractExtensionPaymentResponse> SetDiscountForInstitutionContract([FromBody]InstitutionContractSetDiscountRequest request)
|
||||
public ActionResult<InstitutionContractDiscountResponse> SetDiscountForInstitutionContract([FromBody]InstitutionContractSetDiscountRequest request)
|
||||
{
|
||||
var res = _institutionContractApplication.CalculateDiscount(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("create/reset-discount")]
|
||||
public ActionResult<InstitutionContractExtensionPaymentResponse> ResetDiscountForCreate([FromBody]InstitutionContractResetDiscountForCreateRequest request)
|
||||
public ActionResult<InstitutionContractDiscountResponse> ResetDiscountForCreate([FromBody]InstitutionContractResetDiscountForCreateRequest request)
|
||||
{
|
||||
var res = _institutionContractApplication.ResetDiscountCreate(request);
|
||||
return res;
|
||||
@@ -565,14 +565,14 @@ public class institutionContractController : AdminBaseController
|
||||
}
|
||||
|
||||
[HttpPost("extension/set-discount")]
|
||||
public async Task<ActionResult<InstitutionContractExtensionPaymentResponse>> SetDiscountForExtension([FromBody]InstitutionContractSetDiscountForExtensionRequest request)
|
||||
public async Task<ActionResult<InstitutionContractDiscountResponse>> SetDiscountForExtension([FromBody]InstitutionContractSetDiscountForExtensionRequest request)
|
||||
{
|
||||
var res =await _institutionContractApplication.SetDiscountForExtension(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("extension/reset-discount")]
|
||||
public async Task<ActionResult<InstitutionContractExtensionPaymentResponse>> ResetDiscountForExtension([FromBody]InstitutionContractResetDiscountForExtensionRequest request)
|
||||
public async Task<ActionResult<InstitutionContractDiscountResponse>> ResetDiscountForExtension([FromBody]InstitutionContractResetDiscountForExtensionRequest request)
|
||||
{
|
||||
var res =await _institutionContractApplication.ResetDiscountForExtension(request);
|
||||
return res;
|
||||
|
||||
@@ -55,41 +55,42 @@ public class IndexModel : PageModel
|
||||
|
||||
|
||||
public IActionResult OnGetCreate()
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
var pmRolseSelectList = _roleApplication.GetPmRoleList(null).GetAwaiter().GetResult();
|
||||
var command = new CreateAccount
|
||||
{
|
||||
Roles = _roleApplication.List()
|
||||
};
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
Roles = _roleApplication.List(),
|
||||
RoleList = pmRolseSelectList,
|
||||
};
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
//var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
// { "GozareshgirRoleId", "" }
|
||||
// }
|
||||
//);
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
command.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
//if (response.Success)
|
||||
//{
|
||||
// if (response.Result.isSuccess)
|
||||
// {
|
||||
// command.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
return Partial("./Create", command);
|
||||
}
|
||||
|
||||
|
||||
public IActionResult OnPostCreate(CreateAccount command)
|
||||
{
|
||||
var result = _accountApplication.Create(command);
|
||||
var result = _accountApplication.Create(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public IActionResult OnPostCreateRole(CreateRole command)
|
||||
{
|
||||
var result = _roleApplication.Create(command);
|
||||
var result = _roleApplication.Create(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -112,55 +113,51 @@ public class IndexModel : PageModel
|
||||
|
||||
var account = _accountApplication.GetDetails(id);
|
||||
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
//var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
// $"api/user/{account.Id}",
|
||||
// key
|
||||
//);
|
||||
|
||||
|
||||
var result = _accountApplication.GetPmUserByAccountId(account.Id).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
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)
|
||||
if (result != null)
|
||||
{
|
||||
account.IsProgramManagerUser = (result.Data.accountId == account.Id && result.Data.isActive);
|
||||
account.UserRoles = apiResult.Result.Data.Roles;
|
||||
account.IsProgramManagerUser = (result.AccountId== account.Id && result.IsActive);
|
||||
account.UserRoles = result.Roles;
|
||||
}
|
||||
else
|
||||
{
|
||||
account.IsProgramManagerUser = false;
|
||||
}
|
||||
|
||||
var pmRolseSelectList = _roleApplication.GetPmRoleList(null).GetAwaiter().GetResult();
|
||||
account.RoleList = pmRolseSelectList;
|
||||
|
||||
//var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
// { "GozareshgirRoleId", "" }
|
||||
// }
|
||||
//);
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
//if (response.Success)
|
||||
//{
|
||||
// if (response.Result.isSuccess)
|
||||
// {
|
||||
// account.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
account.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -172,7 +169,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public JsonResult OnPostEdit(EditAccount command)
|
||||
{
|
||||
var result = _accountApplication.Edit(command);
|
||||
var result = _accountApplication.Edit(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -182,26 +179,27 @@ public class IndexModel : PageModel
|
||||
var rol = new List<int>();
|
||||
foreach (var item in role.MappedPermissions) rol.Add(item.Code);
|
||||
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
//var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", role.Id }
|
||||
}
|
||||
);
|
||||
// { "GozareshgirRoleId", role.Id }
|
||||
// }
|
||||
//);
|
||||
|
||||
var pmRoleResult = _roleApplication.GetPmRoleListToEdit(role.Id).GetAwaiter().GetResult();
|
||||
|
||||
role.Permissions = rol;
|
||||
if (apiResult.Success)
|
||||
if (pmRoleResult != null)
|
||||
{
|
||||
if (apiResult.Result.isSuccess && apiResult.Result.data.role.Any())
|
||||
if (pmRoleResult.Any())
|
||||
{
|
||||
var pmPermission = apiResult.Result.data.role.FirstOrDefault()!.permissions;
|
||||
var pmPermission = pmRoleResult.FirstOrDefault()!.Permissions;
|
||||
role.Permissions.AddRange(pmPermission);
|
||||
}
|
||||
|
||||
@@ -213,7 +211,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public JsonResult OnPostEditRole(EditRole command)
|
||||
{
|
||||
var result = _roleApplication.Edit(command);
|
||||
var result = _roleApplication.Edit(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -507,6 +507,13 @@
|
||||
</svg>
|
||||
لیست تراکنش های درگاه پرداخت
|
||||
</a></li>
|
||||
<li permission="307" style=";white-space: nowrap">
|
||||
<a class="clik10 " href="https://admin@(AppSetting.Value.Domain)/account-number-database" style="width: 7px;margin: 0 6px;">
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
|
||||
</svg>
|
||||
اطلاعات بانکی طرف حساب
|
||||
</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
<div class="card-title">قرارداد های مالی</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="countNumber" id="InstitutionContractCount">
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spinner-loading loading" style="display: none;">
|
||||
<span class="spinner-border spinner-border-sm loading text-white" role="status" aria-hidden="true"></span>
|
||||
@@ -192,6 +195,7 @@
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
workFlowStartAndLeftWorkCountMenu();
|
||||
getInstitutionContractCount();
|
||||
|
||||
$('.loadingButton').on('click', function (e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
@@ -235,5 +239,29 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getInstitutionContractCount() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
url: `@Url.Page("./Index", "InstitutionContractCount")`,
|
||||
headers: { "RequestVerificationToken": antiForgeryTokenLayout },
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
if (response.dataInstitutionContractCount === 0) {
|
||||
$('#InstitutionContractCount').hide();
|
||||
} else {
|
||||
$('#InstitutionContractCount').show();
|
||||
var contractCount = response.dataInstitutionContractCount > 99 ? "+99" : response.dataInstitutionContractCount;
|
||||
$('#InstitutionContractCount span').text(contractCount);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.WorkshopAccountAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -18,13 +19,15 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IWorkshopAccountRepository _workshopAccountRepository;
|
||||
public int EmployeeDocumentsAwaitingSubmitCount;
|
||||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||||
private readonly long _roleId;
|
||||
|
||||
public IndexModel(IAdminWorkFlowApplication adminWorkFlowApplication, IAuthHelper authHelper, IWorkshopAccountRepository workshopAccountRepository)
|
||||
public IndexModel(IAdminWorkFlowApplication adminWorkFlowApplication, IAuthHelper authHelper, IWorkshopAccountRepository workshopAccountRepository, IInstitutionContractApplication institutionContractApplication)
|
||||
{
|
||||
_adminWorkFlowApplication = adminWorkFlowApplication;
|
||||
_authHelper = authHelper;
|
||||
_workshopAccountRepository = workshopAccountRepository;
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
_roleId = authHelper.CurrentAccountInfo().RoleId;
|
||||
|
||||
}
|
||||
@@ -49,5 +52,27 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
dataLeftWorkCount = resultLeftWorkCount,
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetInstitutionContractCount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var institutionContractCount = (await _institutionContractApplication.RegistrationWorkflowMainList()).Count;
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
dataInstitutionContractCount = institutionContractCount
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = false,
|
||||
message = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,9 @@ namespace ServiceHost.Areas.AdminNew.Pages
|
||||
{
|
||||
var currentAccountId = _authHelper.CurrentAccountId();
|
||||
var accountWorkshops = _workshopAccountRepository.GetList(currentAccountId).Select(x => x.WorkshopId).ToList();
|
||||
int workFlowCount = await _adminWorkFlowApplication.GetWorkFlowCountsForAdmin(accountWorkshops,currentAccountId, _roleId);
|
||||
var permissions = _authHelper.GetPermissions();
|
||||
|
||||
int workFlowCount = await _adminWorkFlowApplication.GetWorkFlowCountsForAdmin(accountWorkshops,currentAccountId, _roleId,permissions);
|
||||
|
||||
|
||||
return new JsonResult(new
|
||||
|
||||
@@ -655,6 +655,13 @@
|
||||
</svg>
|
||||
لیست تراکنش های درگاه پرداخت
|
||||
</a></li>
|
||||
<li permission="307" style=";white-space: nowrap">
|
||||
<a class="clik10 " href="https://admin@(AppSetting.Value.Domain)/account-number-database" style="width: 7px;margin: 0 6px;">
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
|
||||
</svg>
|
||||
اطلاعات بانکی طرف حساب
|
||||
</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddHttpClient("holidayApi", c => c.BaseAddress = new System.Uri("https://api.github.com"));
|
||||
var connectionString = builder.Configuration.GetConnectionString("MesbahDb");
|
||||
var connectionStringTestDb = builder.Configuration.GetConnectionString("TestDb");
|
||||
var connectionStringProgramManager = builder.Configuration.GetConnectionString("ProgramManagerDb");
|
||||
|
||||
#region MongoDb
|
||||
|
||||
@@ -68,6 +69,7 @@ builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
|
||||
builder.Services.AddSingleton<IActionResultExecutor<JsonResult>, CustomJsonResultExecutor>();
|
||||
PersonalBootstrapper.Configure(builder.Services, connectionString);
|
||||
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
|
||||
PmDbBootstrapper.Configure(builder.Services, connectionStringProgramManager);
|
||||
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
|
||||
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
|
||||
QueryBootstrapper.Configure(builder.Services);
|
||||
@@ -333,11 +335,8 @@ builder.Services.AddParbad().ConfigureGateways(gateways =>
|
||||
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
|
||||
|
||||
app.UseCors("AllowSpecificOrigins");
|
||||
|
||||
#region InternalProgarmManagerApi
|
||||
@@ -365,7 +364,7 @@ app.Use(async (context, next) =>
|
||||
});
|
||||
|
||||
|
||||
// مقداردهی به کلاس Static
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"sqlDebugging": true,
|
||||
"dotnetRunMessages": "true",
|
||||
"nativeDebugging": true,
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5005",
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
|
||||
"jsWebView2Debugging": false,
|
||||
"hotReloadEnabled": true
|
||||
},
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=185.208.175.186;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;",
|
||||
|
||||
//dad-mehr
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;"
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
//program_manager_db
|
||||
"ProgramManagerDb": "Data Source=.;Initial Catalog=program_manager_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
//mahan Docker
|
||||
//"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;"
|
||||
},
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//testDb
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;"
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//program_manager_db
|
||||
"ProgramManagerDb": "Data Source=.;Initial Catalog=program_manager_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
},
|
||||
"BackupOptions": {
|
||||
"DbName": "mesbah_db",
|
||||
@@ -41,7 +44,7 @@
|
||||
"Dadmehrg": "https://api.pm.dadmehrg.ir",
|
||||
"Gozareshgir": "https://api.pm.gozareshgir.ir"
|
||||
},
|
||||
|
||||
|
||||
|
||||
"SepehrGateWayTerminalId": 99213700
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public interface IAdminWorkFlowApplication
|
||||
#endregion
|
||||
|
||||
Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds, long roleId);
|
||||
Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId);
|
||||
Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId, List<int> permissions);
|
||||
Task<int> GetWorkFlowCountForChecker();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public interface IAdminWorkFlowApplication
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Task<int> GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using CompanyManagment.App.Contracts.Employee;
|
||||
using WorkFlow.Application.Contracts.AdminWorkFlow;
|
||||
using WorkFlow.Infrastructure.ACL.Employee;
|
||||
using WorkFlow.Infrastructure.ACL.EmployeeDocuments;
|
||||
using WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
using WorkFlow.Infrastructure.ACL.Workshop;
|
||||
|
||||
namespace WorkFlow.Application
|
||||
@@ -12,65 +13,76 @@ namespace WorkFlow.Application
|
||||
private readonly IWorkFlowEmployeeDocumentsACL _workFlowEmployeeDocumentsACL;
|
||||
private readonly IWorkFlowWorkshopACL _workFlowWorkshopACL;
|
||||
private readonly IWorkFlowEmployeeACL _workFlowEmployeeACL;
|
||||
private readonly IWorkFlowInstitutionContractACL _workFlowInstitutionContractACL;
|
||||
|
||||
|
||||
public AdminWorkFlowApplication(IWorkFlowEmployeeDocumentsACL workFlowEmployeeDocumentsACL, IWorkFlowWorkshopACL workFlowWorkshopACL, IWorkFlowEmployeeACL workFlowEmployeeACL)
|
||||
public AdminWorkFlowApplication(IWorkFlowEmployeeDocumentsACL workFlowEmployeeDocumentsACL,
|
||||
IWorkFlowWorkshopACL workFlowWorkshopACL, IWorkFlowEmployeeACL workFlowEmployeeACL,
|
||||
IWorkFlowInstitutionContractACL workFlowInstitutionContractACL)
|
||||
{
|
||||
_workFlowEmployeeDocumentsACL = workFlowEmployeeDocumentsACL;
|
||||
_workFlowWorkshopACL = workFlowWorkshopACL;
|
||||
_workFlowEmployeeACL = workFlowEmployeeACL;
|
||||
_workFlowInstitutionContractACL = workFlowInstitutionContractACL;
|
||||
}
|
||||
|
||||
#region Pooya
|
||||
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopDocumentsAwaitingReviewForChecker(List<long> workshops)
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopDocumentsAwaitingReviewForChecker(
|
||||
List<long> workshops)
|
||||
{
|
||||
return _workFlowEmployeeDocumentsACL.GetWorkshopDocumentsAwaitingReviewForChecker(workshops);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds,long roleId)
|
||||
public async Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds, long roleId)
|
||||
{
|
||||
var count = 0;
|
||||
count += await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentRejectedForAdmin(workshopIds,roleId);
|
||||
count += await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentRejectedForAdmin(workshopIds, roleId);
|
||||
|
||||
count+= await _workFlowEmployeeDocumentsACL.GetCreatedEmployeesWorkshopDocumentForAdmin(workshopIds,roleId);
|
||||
count += await _workFlowEmployeeDocumentsACL.GetCreatedEmployeesWorkshopDocumentForAdmin(workshopIds,
|
||||
roleId);
|
||||
|
||||
//count+= await _workFlowEmployeeDocumentsACL.GetClientRejectedDocumentWorkshopsForAdmin(workshopIds, roleId);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId,long roleId)
|
||||
public async Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId,
|
||||
List<int> permissions)
|
||||
{
|
||||
var employeeDocumentWorkFlowCounts = await GetEmployeeDocumentWorkFlowCountsForAdmin(workshopIds, roleId);
|
||||
var startWork = await GetWorkshopsForEmployeeStartWorkCount(accountId);
|
||||
var leftWork = await GetWorkshopsForLeftWorkTempCount(accountId);
|
||||
int institutionContract = 0;
|
||||
if (permissions.Any(x => x == 1004))
|
||||
{
|
||||
institutionContract = await GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
return employeeDocumentWorkFlowCounts + startWork + leftWork;
|
||||
return employeeDocumentWorkFlowCounts + startWork + leftWork +institutionContract;
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkFlowCountForChecker()
|
||||
{
|
||||
return await _workFlowEmployeeDocumentsACL.GetCheckerWorkFlowCount();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopsWithDocumentsAwaitingUploadForAdmin(List<long> workshops)
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopsWithDocumentsAwaitingUploadForAdmin(
|
||||
List<long> workshops)
|
||||
{
|
||||
return _workFlowEmployeeDocumentsACL.GetWorkshopsWithDocumentsAwaitingUploadForAdmin(workshops);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
#region شروع به کار پرسنل افزوده شده
|
||||
public async Task<ICollection<WorkshopWithStartedWorkWorkFlowViewModel>> GetWorkshopsForEmployeeStartWork(long accountId)
|
||||
|
||||
public async Task<ICollection<WorkshopWithStartedWorkWorkFlowViewModel>> GetWorkshopsForEmployeeStartWork(
|
||||
long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForEmployeeStartWork(accountId);
|
||||
}
|
||||
@@ -81,14 +93,14 @@ namespace WorkFlow.Application
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesWorkFlowViewModel>> GetClientEmployeesStartWork(long workshopId)
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesWorkFlowViewModel>> GetClientEmployeesStartWork(
|
||||
long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetClientEmployeesStartWork(workshopId);
|
||||
}
|
||||
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(
|
||||
long employeeId, long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetEmployeeEditInEmployeeDocumentWorkFlow(employeeId, workshopId);
|
||||
}
|
||||
@@ -103,16 +115,24 @@ namespace WorkFlow.Application
|
||||
|
||||
#region ترک کار موقت
|
||||
|
||||
public async Task<ICollection<WorkshopWithLeftWorkWorkFlowViewModel>> GetWorkshopsForLeftWorkTemp(long accountId)
|
||||
public async Task<ICollection<WorkshopWithLeftWorkWorkFlowViewModel>> GetWorkshopsForLeftWorkTemp(
|
||||
long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForLeftWorkTemp(accountId);
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkshopsForLeftWorkTempCount(long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForLeftWorkTempCount(accountId);
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkEmployeesWorkFlowViewModel>> GetEmployeesForLeftWorkTemp(long workshopId)
|
||||
public async Task<int> GetInstitutionContractWorkflowCount()
|
||||
{
|
||||
return await _workFlowInstitutionContractACL.GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkEmployeesWorkFlowViewModel>> GetEmployeesForLeftWorkTemp(
|
||||
long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetEmployeesForLeftWorkTemp(workshopId);
|
||||
}
|
||||
@@ -121,7 +141,8 @@ namespace WorkFlow.Application
|
||||
|
||||
#region آپلود مدارک پرسنل
|
||||
|
||||
public async Task<ICollection<WorkshopWithDocumentsViewModelForWorkFlow>> GetWorkshopDocumentCreatedEmployeeForAdmin(List<long> workshops, long roleId)
|
||||
public async Task<ICollection<WorkshopWithDocumentsViewModelForWorkFlow>>
|
||||
GetWorkshopDocumentCreatedEmployeeForAdmin(List<long> workshops, long roleId)
|
||||
{
|
||||
return await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentCreatedEmployeeForAdmin(workshops, roleId);
|
||||
}
|
||||
@@ -130,6 +151,4 @@ namespace WorkFlow.Application
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,5 @@ public class WorkFlowEmployeeACL : IWorkFlowEmployeeACL
|
||||
{
|
||||
return await _employeeApplication.EditEmployeeInEmployeeDocumentWorkFlow(command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
namespace WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
|
||||
public interface IWorkFlowInstitutionContractACL
|
||||
{
|
||||
Task<int> GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
public class WorkFlowInstitutionContractACL : IWorkFlowInstitutionContractACL
|
||||
{
|
||||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||||
public WorkFlowInstitutionContractACL(IInstitutionContractApplication institutionContractApplication)
|
||||
{
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
}
|
||||
|
||||
public async Task<int> GetInstitutionContractWorkflowCount()
|
||||
{
|
||||
var list = await _institutionContractApplication.RegistrationWorkflowMainList();
|
||||
return list.Count;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using WorkFlow.Infrastructure.ACL.Checkout;
|
||||
using WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings;
|
||||
using WorkFlow.Infrastructure.ACL.Employee;
|
||||
using WorkFlow.Infrastructure.ACL.EmployeeDocuments;
|
||||
using WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
using WorkFlow.Infrastructure.ACL.RollCall;
|
||||
using WorkFlow.Infrastructure.ACL.Workshop;
|
||||
using WorkFlow.Infrastructure.EfCore;
|
||||
@@ -33,8 +34,7 @@ namespace WorkFlow.Infrastructure.Config
|
||||
services.AddTransient<IWorkFlowRollCallACL, WorkFlowRollCallACL>();
|
||||
services.AddTransient<IWorkFlowCustomizedWorkshopSettingsACL, WorkFlowCustomizedWorkshopSettingsACL>();
|
||||
services.AddTransient<IWorkFlowEmployeeACL, WorkFlowEmployeeACL>();
|
||||
|
||||
|
||||
services.AddTransient<IWorkFlowInstitutionContractACL, WorkFlowInstitutionContractACL>();
|
||||
services.AddTransient<IWorkFlowWorkshopACL, WorkFlowWorkshopACL>();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user