Compare commits
81 Commits
Feature/ro
...
Feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
| 989f216b9a | |||
| cd64e1d24d | |||
| d9da2e97ab | |||
|
|
1c1c8816a5 | ||
| a1e85261a6 | |||
| 000af89fd7 | |||
|
|
a4f3feba1c | ||
|
|
a3d286c040 | ||
|
|
902ef34757 | ||
|
|
e67aca37f9 | ||
| 2a31b27f9b | |||
| e05eb1236b | |||
| a7d3b1e96f | |||
| 73bef104fb | |||
|
|
b31559a29a | ||
|
|
e62270a9b7 | ||
|
|
998759e2dc | ||
|
|
49d401856f | ||
|
|
2faf6c1400 | ||
|
|
a01a927f6f | ||
| bca1e66f0f | |||
|
|
097d5a6e86 | ||
| 83a7bbf5f3 | |||
|
|
24501df615 | ||
| da46d45601 | |||
| 14fda440c1 | |||
| 85ce92af2c | |||
|
|
5777a869cf | ||
| ed6301831c | |||
| 2d0eb52211 | |||
| 05d8b738cc | |||
|
|
5936f02421 | ||
|
|
57116b14cc | ||
| a1e52ca48a | |||
| f75d267ef5 | |||
| 5be44432b1 | |||
|
|
c0d2cae82e | ||
|
|
955a6a3d21 | ||
| a52e313984 | |||
| 58816ca383 | |||
| 370feca81e | |||
|
|
a4bf6c952d | ||
|
|
c9d582877b | ||
| 339cea998a | |||
| 32065aec33 | |||
| f2293934d4 | |||
| b12b3b9eb8 | |||
| 91259046f6 | |||
| c9882f0b59 | |||
|
|
e89aae1cc9 | ||
| 9469a5f76e | |||
| c059066b13 | |||
| ba0669bc55 | |||
| f42db3d21c | |||
| f829b8ddd1 | |||
| 5e6033db95 | |||
| 27e8a26ed8 | |||
|
|
0a2815946c | ||
|
|
7776dedd2a | ||
|
|
5da523e9a8 | ||
| b7a7fb01d7 | |||
| 8d49220532 | |||
|
|
def27929d9 | ||
|
|
ea6fcbc773 | ||
| 788d58b413 | |||
| de8181770d | |||
| 3a32d1ca9d | |||
| 951a194961 | |||
|
|
32a05398de | ||
|
|
57853e2d1f | ||
|
|
acd96bcdc7 | ||
| 517f2d06ca | |||
|
|
fb97d3453d | ||
|
|
2320185ade | ||
|
|
80fdd1fece | ||
| 323a46a623 | |||
|
|
901a4ebd35 | ||
|
|
16b04fc75c | ||
|
|
86ac300e00 | ||
|
|
90a420c8c5 | ||
|
|
73563b0421 |
@@ -1,21 +1,25 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<RootNamespace>_0_Framework</RootNamespace>
|
<RootNamespace>_0_Framework</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="IPE.SmsIR" Version="1.0.5" />
|
<PackageReference Include="IPE.SmsIR" Version="1.2.7" />
|
||||||
<PackageReference Include="EPPlus" Version="7.5.2" />
|
<PackageReference Include="EPPlus" Version="8.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.1.34" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.3" />
|
||||||
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
|
<PackageReference Include="System.Drawing.Common" Version="10.0.1" />
|
||||||
<PackageReference Include="MD.PersianDateTime.Standard" Version="2.5.0" />
|
<PackageReference Include="MD.PersianDateTime.Standard" Version="2.6.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.2.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.0.1" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.1" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ public class AuthHelper : IAuthHelper
|
|||||||
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
|
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasPermission(int permission)
|
||||||
|
{
|
||||||
|
return GetPermissions().Any(x => x == permission);
|
||||||
|
}
|
||||||
|
|
||||||
public long CurrentAccountId()
|
public long CurrentAccountId()
|
||||||
{
|
{
|
||||||
return IsAuthenticated()
|
return IsAuthenticated()
|
||||||
@@ -198,7 +203,8 @@ public class AuthHelper : IAuthHelper
|
|||||||
new("workshopList",workshopBson),
|
new("workshopList",workshopBson),
|
||||||
new("WorkshopSlug",slug),
|
new("WorkshopSlug",slug),
|
||||||
new("WorkshopId", account.WorkshopId.ToString()),
|
new("WorkshopId", account.WorkshopId.ToString()),
|
||||||
new("WorkshopName",account.WorkshopName??"")
|
new("WorkshopName",account.WorkshopName??""),
|
||||||
|
new("pm.userId", account.PmUserId.ToString()),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ public class AuthViewModel
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public long SubAccountId { get; set; }
|
public long SubAccountId { get; set; }
|
||||||
|
public long? PmUserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public AuthViewModel(long id, long roleId, string fullname, string username, string mobile,string profilePhoto,
|
public AuthViewModel(long id, long roleId, string fullname, string username, string mobile,string profilePhoto,
|
||||||
List<int> permissions, string roleName, string adminAreaPermission, string clientAriaPermission, int? positionValue, long subAccountId = 0)
|
List<int> permissions, string roleName, string adminAreaPermission, string clientAriaPermission, int? positionValue,
|
||||||
|
long subAccountId = 0,long? pmUserId = null)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
RoleId = roleId;
|
RoleId = roleId;
|
||||||
@@ -44,6 +46,7 @@ public class AuthViewModel
|
|||||||
ClientAriaPermission = clientAriaPermission;
|
ClientAriaPermission = clientAriaPermission;
|
||||||
PositionValue = positionValue;
|
PositionValue = positionValue;
|
||||||
SubAccountId = subAccountId;
|
SubAccountId = subAccountId;
|
||||||
|
PmUserId = pmUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthViewModel()
|
public AuthViewModel()
|
||||||
|
|||||||
@@ -33,4 +33,9 @@ public enum TypeOfSmsSetting
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
LegalAction,
|
LegalAction,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پیامک تایید قراداد
|
||||||
|
/// </summary>
|
||||||
|
InstitutionContractConfirm,
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ public interface IAuthHelper
|
|||||||
string CurrentAccountRole();
|
string CurrentAccountRole();
|
||||||
AuthViewModel CurrentAccountInfo();
|
AuthViewModel CurrentAccountInfo();
|
||||||
List<int> GetPermissions();
|
List<int> GetPermissions();
|
||||||
|
bool HasPermission(int permission);
|
||||||
long CurrentAccountId();
|
long CurrentAccountId();
|
||||||
string CurrentAccountMobile();
|
string CurrentAccountMobile();
|
||||||
|
|
||||||
|
|||||||
13
0_Framework/Application/SecretKeys.cs
Normal file
13
0_Framework/Application/SecretKeys.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace _0_Framework.Application;
|
||||||
|
|
||||||
|
public static class SecretKeys
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string ProgramManagerInternalApi => "JOb09$Ic3NJd0siLCJtYWMiOiI2%dmODJmNDV";
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using AccountManagement.Application.Contracts.Role;
|
using AccountManagement.Application.Contracts.Role;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Account;
|
namespace AccountManagement.Application.Contracts.Account;
|
||||||
|
|
||||||
@@ -35,4 +36,20 @@ public class CreateAccount
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string VerifyCode { get; set; }
|
public string VerifyCode { get; set; }
|
||||||
public string IsActiveString { get; set; }
|
public string IsActiveString { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا کاربر در پروگرام منیجر فعالیت مبکند؟
|
||||||
|
/// </summary>
|
||||||
|
public bool IsProgramManagerUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// لیست نقش های پروگرام منیجر
|
||||||
|
/// </summary>
|
||||||
|
public List<long> UserRoles { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست نقشهای موجود در پروگرام منیجر
|
||||||
|
/// </summary>
|
||||||
|
public SelectList RoleList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,5 @@
|
|||||||
public class EditAccount : CreateAccount
|
public class EditAccount : CreateAccount
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AccountManagement.Application.Contracts.Account;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Account;
|
|
||||||
|
|
||||||
public class EditClientAccount : RegisterAccount
|
public class EditClientAccount : RegisterAccount
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Shared.Contracts.PmUser.Queries;
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Account;
|
namespace AccountManagement.Application.Contracts.Account;
|
||||||
|
|
||||||
public interface IAccountApplication
|
public interface IAccountApplication
|
||||||
{
|
{
|
||||||
AccountViewModel GetAccountBy(long id);
|
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 RegisterClient(RegisterAccount command);
|
||||||
OperationResult Edit(EditAccount command);
|
Task<OperationResult> Edit(EditAccount command);
|
||||||
OperationResult EditClient(EditClientAccount command);
|
OperationResult EditClient(EditClientAccount command);
|
||||||
OperationResult ChangePassword(ChangePassword command);
|
OperationResult ChangePassword(ChangePassword command);
|
||||||
OperationResult Login(Login command);
|
OperationResult Login(Login command);
|
||||||
@@ -67,6 +73,9 @@ public interface IAccountApplication
|
|||||||
List<AccountViewModel> GetAdminAccountsNew();
|
List<AccountViewModel> GetAdminAccountsNew();
|
||||||
|
|
||||||
void CameraLogin(CameraLoginRequest request);
|
void CameraLogin(CameraLoginRequest request);
|
||||||
|
|
||||||
|
Task<GetPmUserDto> GetPmUserAsync(long accountId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CameraLoginRequest
|
public class CameraLoginRequest
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Application;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Account;
|
namespace AccountManagement.Application.Contracts.Account;
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AccountManagement.Application.Contracts.Account;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Account;
|
|
||||||
|
|
||||||
public class WorkshopSelectList
|
public class WorkshopSelectList
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
||||||
|
<ProjectReference Include="..\Shared.Contracts\Shared.Contracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
public record ApiResponse
|
||||||
|
{
|
||||||
|
public bool isSuccess { get; set; }
|
||||||
|
public string errorMessage { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ErrorType ErrorType { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
|
||||||
|
public record CreateProgramManagerRole
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// نام نقش
|
||||||
|
/// </summary>
|
||||||
|
public string RoleName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کدهای دسترسی
|
||||||
|
/// </summary>
|
||||||
|
public List<int> Permissions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی اکانت گزارشگیر
|
||||||
|
/// </summary>
|
||||||
|
public long? GozareshgirRoleId { get; set; }
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
public record CreateProgramManagerUser(string FullName, string UserName, string Password, string Mobile, string Email, long? AccountId, List<long> Roles);
|
||||||
|
|
||||||
|
public record EditUserCommand(string FullName, string UserName, string Mobile, long AccountId, List<long> Roles, bool IsActive);
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
public enum ErrorType
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
BadRequest,
|
||||||
|
NotFound,
|
||||||
|
Unauthorized,
|
||||||
|
Validation,
|
||||||
|
InternalServerError
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
public class RoleResponse
|
||||||
|
{
|
||||||
|
public bool isSuccess { get; set; }
|
||||||
|
public RolesData data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RolesData
|
||||||
|
{
|
||||||
|
public List<RoleList> role { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RoleList
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string roleName { get; set; }
|
||||||
|
public int gozareshgirRoleId { get; set; }
|
||||||
|
public List<int> permissions { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
|
namespace AccountManagement.Application.Contracts.ProgramManagerApiResult;
|
||||||
|
|
||||||
|
public record SingleUserResponseResult
|
||||||
|
{
|
||||||
|
public bool isSuccess { get; set; }
|
||||||
|
public SingleUserData Data { get; set; }
|
||||||
|
};
|
||||||
|
|
||||||
|
public record SingleUserData
|
||||||
|
|
||||||
|
{
|
||||||
|
public long id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// نام و نام خانوادگی
|
||||||
|
/// </summary>
|
||||||
|
public string fullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کاربری
|
||||||
|
/// </summary>
|
||||||
|
public string userName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مسیر عکس پروفایل
|
||||||
|
/// </summary>
|
||||||
|
public string profilePhotoPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره موبایل
|
||||||
|
/// </summary>
|
||||||
|
public string mobile { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// فعال/غیر فعال بودن یوزر
|
||||||
|
/// </summary>
|
||||||
|
public bool isActive { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// گذرواژه
|
||||||
|
/// </summary>
|
||||||
|
public string password { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ای دی اکانت کاربر در گزارشگیر
|
||||||
|
/// </summary>
|
||||||
|
public long? accountId { get; set; }
|
||||||
|
|
||||||
|
public List<long> Roles { get; set; }
|
||||||
|
}
|
||||||
@@ -9,6 +9,10 @@ namespace AccountManagement.Application.Contracts.Role
|
|||||||
[Required(ErrorMessage = ValidationMessages.IsRequired)]
|
[Required(ErrorMessage = ValidationMessages.IsRequired)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public List<int> Permissions { get; set; }
|
public List<int> Permissions { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// لیست پرمیشن های پروگرام منیجر
|
||||||
|
/// </summary>
|
||||||
|
public List<int> PmPermissions { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Shared.Contracts.PmRole.Queries;
|
||||||
|
|
||||||
namespace AccountManagement.Application.Contracts.Role
|
namespace AccountManagement.Application.Contracts.Role
|
||||||
{
|
{
|
||||||
public interface IRoleApplication
|
public interface IRoleApplication
|
||||||
{
|
{
|
||||||
OperationResult Create(CreateRole command);
|
Task<OperationResult> Create(CreateRole command);
|
||||||
OperationResult Edit(EditRole command);
|
Task<OperationResult> Edit(EditRole command);
|
||||||
List<RoleViewModel> List();
|
List<RoleViewModel> List();
|
||||||
EditRole GetDetails(long id);
|
EditRole GetDetails(long id);
|
||||||
|
|
||||||
|
#region ProgramManager
|
||||||
|
|
||||||
|
Task<SelectList> GetPmRoleList(long? gozareshgirRoleId);
|
||||||
|
Task<List<GetPmRolesDto>> GetPmRoleListToEdit(long? gozareshgirRoleId);
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,26 @@
|
|||||||
using System;
|
using _0_Framework.Application;
|
||||||
using System.Collections;
|
using _0_Framework.Application.Sms;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Exceptions;
|
||||||
using AccountManagement.Application.Contracts.Account;
|
using AccountManagement.Application.Contracts.Account;
|
||||||
using AccountManagement.Domain.AccountAgg;
|
using AccountManagement.Domain.AccountAgg;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Application.Sms;
|
|
||||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||||
using AccountManagement.Domain.CameraAccountAgg;
|
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 _0_Framework.Exceptions;
|
|
||||||
using AccountManagement.Domain.PositionAgg;
|
using AccountManagement.Domain.PositionAgg;
|
||||||
|
using AccountManagement.Domain.RoleAgg;
|
||||||
using AccountManagement.Domain.SubAccountAgg;
|
using AccountManagement.Domain.SubAccountAgg;
|
||||||
using AccountManagement.Domain.SubAccountPermissionSubtitle1Agg;
|
using AccountManagement.Domain.SubAccountPermissionSubtitle1Agg;
|
||||||
using AccountManagement.Domain.SubAccountRoleAgg;
|
using AccountManagement.Domain.SubAccountRoleAgg;
|
||||||
|
using Company.Domain._common;
|
||||||
|
using Company.Domain.WorkshopAgg;
|
||||||
using Company.Domain.WorkshopSubAccountAgg;
|
using Company.Domain.WorkshopSubAccountAgg;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Shared.Contracts.PmUser.Commands;
|
||||||
|
using Shared.Contracts.PmUser.Queries;
|
||||||
|
|
||||||
//using AccountManagement.Domain.RoleAgg;
|
//using AccountManagement.Domain.RoleAgg;
|
||||||
|
|
||||||
@@ -39,15 +36,19 @@ public class AccountApplication : IAccountApplication
|
|||||||
private readonly ISmsService _smsService;
|
private readonly ISmsService _smsService;
|
||||||
private readonly ICameraAccountRepository _cameraAccountRepository;
|
private readonly ICameraAccountRepository _cameraAccountRepository;
|
||||||
private readonly IPositionRepository _positionRepository;
|
private readonly IPositionRepository _positionRepository;
|
||||||
private readonly IAccountLeftworkRepository _accountLeftworkRepository;
|
private readonly IAccountLeftworkRepository _accountLeftworkRepository;
|
||||||
private readonly IWorkshopRepository _workshopRepository;
|
private readonly IWorkshopRepository _workshopRepository;
|
||||||
private readonly ISubAccountRepository _subAccountRepository;
|
private readonly ISubAccountRepository _subAccountRepository;
|
||||||
private readonly ISubAccountRoleRepository _subAccountRoleRepository;
|
private readonly ISubAccountRoleRepository _subAccountRoleRepository;
|
||||||
private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository;
|
private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository;
|
||||||
private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository;
|
private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository;
|
||||||
|
|
||||||
public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher,
|
private readonly 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)
|
private readonly IPmUserQueryService _pmUserQueryService;
|
||||||
|
private readonly IPmUserCommandService _pmUserCommandService;
|
||||||
|
|
||||||
|
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, IPmUserQueryService pmUserQueryService, IPmUserCommandService pmUserCommandService)
|
||||||
{
|
{
|
||||||
_authHelper = authHelper;
|
_authHelper = authHelper;
|
||||||
_roleRepository = roleRepository;
|
_roleRepository = roleRepository;
|
||||||
@@ -60,10 +61,14 @@ public class AccountApplication : IAccountApplication
|
|||||||
_subAccountRoleRepository = subAccountRoleRepository;
|
_subAccountRoleRepository = subAccountRoleRepository;
|
||||||
_workshopSubAccountRepository = workshopSubAccountRepository;
|
_workshopSubAccountRepository = workshopSubAccountRepository;
|
||||||
_accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository;
|
_accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
|
||||||
|
_pmUserQueryService = pmUserQueryService;
|
||||||
|
_pmUserCommandService = pmUserCommandService;
|
||||||
_fileUploader = fileUploader;
|
_fileUploader = fileUploader;
|
||||||
_passwordHasher = passwordHasher;
|
_passwordHasher = passwordHasher;
|
||||||
_accountRepository = accountRepository;
|
_accountRepository = accountRepository;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult EditClient(EditClientAccount command)
|
public OperationResult EditClient(EditClientAccount command)
|
||||||
@@ -92,7 +97,7 @@ public class AccountApplication : IAccountApplication
|
|||||||
|
|
||||||
var path = $"profilePhotos";
|
var path = $"profilePhotos";
|
||||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||||
editAccount.EditClient(command.Fullname,command.Username,command.Mobile,picturePath,command.Email,command.NationalCode);
|
editAccount.EditClient(command.Fullname, command.Username, command.Mobile, picturePath, command.Email, command.NationalCode);
|
||||||
_accountRepository.SaveChanges();
|
_accountRepository.SaveChanges();
|
||||||
return opreation.Succcedded();
|
return opreation.Succcedded();
|
||||||
}
|
}
|
||||||
@@ -123,7 +128,7 @@ public class AccountApplication : IAccountApplication
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Create(CreateAccount command)
|
public async Task<OperationResult> Create(CreateAccount command)
|
||||||
{
|
{
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
|
|
||||||
@@ -133,15 +138,57 @@ public class AccountApplication : IAccountApplication
|
|||||||
var password = _passwordHasher.Hash(command.Password);
|
var password = _passwordHasher.Hash(command.Password);
|
||||||
var roleName = _roleRepository.GetDetails(command.RoleId);
|
var roleName = _roleRepository.GetDetails(command.RoleId);
|
||||||
var path = $"profilePhotos";
|
var path = $"profilePhotos";
|
||||||
|
var picturePath = "";
|
||||||
if (_fileUploader != null)
|
if (_fileUploader != null)
|
||||||
{
|
{
|
||||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||||
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
|
||||||
picturePath, roleName.Name,"true","false");
|
}
|
||||||
_accountRepository.Create(account);
|
var account = new Account(command.Fullname, command.Username, password, command.Mobile, command.RoleId,
|
||||||
|
picturePath, roleName.Name, "true", "false");
|
||||||
|
|
||||||
|
_unitOfWork.BeginAccountContext();
|
||||||
|
|
||||||
|
|
||||||
|
_accountRepository.Create(account);
|
||||||
|
_accountRepository.SaveChanges();
|
||||||
|
|
||||||
|
if (command.IsProgramManagerUser)
|
||||||
|
{
|
||||||
|
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
|
||||||
|
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||||
|
null, account.id, pmUserRoles));
|
||||||
|
if (!createPm.isSuccess)
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//var url = "api/user/create";
|
||||||
|
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||||
|
|
||||||
|
//var response = InternalApiCaller.PostAsync<CreateProgramManagerUser, ApiResponse>(
|
||||||
|
// url,
|
||||||
|
// key,
|
||||||
|
// parameters
|
||||||
|
//);
|
||||||
|
|
||||||
|
//if (!response.Success)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Error);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (!response.Result.isSuccess)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Result.errorMessage);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
_accountRepository.SaveChanges();
|
_unitOfWork.CommitAccountContext();
|
||||||
return operation.Succcedded();
|
return operation.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +202,8 @@ public class AccountApplication : IAccountApplication
|
|||||||
return opreation.Failed("پر کردن تمامی فیلدها الزامی است");
|
return opreation.Failed("پر کردن تمامی فیلدها الزامی است");
|
||||||
if (_accountRepository.Exists(x => x.Username == command.Username))
|
if (_accountRepository.Exists(x => x.Username == command.Username))
|
||||||
return opreation.Failed("نام کاربری تکراری است");
|
return opreation.Failed("نام کاربری تکراری است");
|
||||||
if (_accountRepository.Exists(x => x.Mobile == command.Mobile && x.IsActiveString =="true"))
|
if (_accountRepository.Exists(x => x.Mobile == command.Mobile && x.IsActiveString == "true"))
|
||||||
|
|
||||||
return opreation.Failed("مقادیر وارد شده تکراری است");
|
return opreation.Failed("مقادیر وارد شده تکراری است");
|
||||||
|
|
||||||
//var nationalCodeValidation = command.NationalCode.NationalCodeValid();
|
//var nationalCodeValidation = command.NationalCode.NationalCodeValid();
|
||||||
@@ -173,14 +220,14 @@ public class AccountApplication : IAccountApplication
|
|||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
var password = _passwordHasher.Hash(command.Password);
|
var password = _passwordHasher.Hash(command.Password);
|
||||||
var register =new Account(command.Fullname,command.Username, password, command.Mobile, command.NationalCode);
|
var register = new Account(command.Fullname, command.Username, password, command.Mobile, command.NationalCode);
|
||||||
_accountRepository.Create(register);
|
_accountRepository.Create(register);
|
||||||
_accountRepository.SaveChanges();
|
_accountRepository.SaveChanges();
|
||||||
|
|
||||||
return opreation.Succcedded(register.id,message: "ثبت نام شما با موفقیت انجام شد");
|
return opreation.Succcedded(register.id, message: "ثبت نام شما با موفقیت انجام شد");
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Edit(EditAccount command)
|
public async Task<OperationResult> Edit(EditAccount command)
|
||||||
{
|
{
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
var account = _accountRepository.Get(command.Id);
|
var account = _accountRepository.Get(command.Id);
|
||||||
@@ -194,8 +241,127 @@ public class AccountApplication : IAccountApplication
|
|||||||
var roleName = _roleRepository.GetDetails(command.RoleId);
|
var roleName = _roleRepository.GetDetails(command.RoleId);
|
||||||
var path = $"profilePhotos";
|
var path = $"profilePhotos";
|
||||||
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
var picturePath = _fileUploader.Upload(command.ProfilePhoto, path);
|
||||||
|
_unitOfWork.BeginAccountContext();
|
||||||
account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath, roleName.Name);
|
account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath, roleName.Name);
|
||||||
_accountRepository.SaveChanges();
|
_accountRepository.SaveChanges();
|
||||||
|
var key = SecretKeys.ProgramManagerInternalApi;
|
||||||
|
|
||||||
|
//var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||||
|
// $"api/user/{account.id}",
|
||||||
|
// key
|
||||||
|
//);
|
||||||
|
var userResult =await _pmUserQueryService.GetPmUserDataByAccountId(account.id);
|
||||||
|
|
||||||
|
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
|
||||||
|
|
||||||
|
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده
|
||||||
|
if (userResult.Id >0)
|
||||||
|
{
|
||||||
|
if (!command.UserRoles.Any())
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||||
|
}
|
||||||
|
|
||||||
|
var editPm =await _pmUserCommandService.Edit(new EditPmUserDto(command.Fullname, command.Username, command.Mobile, account.id, pmUserRoles,
|
||||||
|
command.IsProgramManagerUser));
|
||||||
|
if (!editPm.isSuccess)
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
|
||||||
|
}
|
||||||
|
|
||||||
|
//var parameters = new EditUserCommand(
|
||||||
|
// command.Fullname,
|
||||||
|
// command.Username,
|
||||||
|
// command.Mobile,
|
||||||
|
// account.id,
|
||||||
|
// command.UserRoles,
|
||||||
|
// command.IsProgramManagerUser
|
||||||
|
//);
|
||||||
|
//var url = "api/user/edit";
|
||||||
|
//var response = InternalApiCaller.PostAsync<EditUserCommand, ApiResponse>(
|
||||||
|
// url,
|
||||||
|
// key,
|
||||||
|
// parameters
|
||||||
|
//);
|
||||||
|
|
||||||
|
//if (!response.Success)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Error);
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (!response.Result.isSuccess)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Error);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
else //اگر کاربر قبلا ایجاد نشده
|
||||||
|
{
|
||||||
|
//اگر تیک فعالیت در پروگرام منیجر روشن بود
|
||||||
|
if (command.IsProgramManagerUser)
|
||||||
|
{
|
||||||
|
if (!command.UserRoles.Any())
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("حداقل یک نقش باید انتخاب شود");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
|
||||||
|
null, account.id, pmUserRoles));
|
||||||
|
if (!createPm.isSuccess)
|
||||||
|
{
|
||||||
|
_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);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_unitOfWork.CommitAccountContext();
|
||||||
return operation.Succcedded();
|
return operation.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,18 +376,18 @@ public class AccountApplication : IAccountApplication
|
|||||||
long idAutoriz = 0;
|
long idAutoriz = 0;
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
if (string.IsNullOrWhiteSpace(command.Password))
|
if (string.IsNullOrWhiteSpace(command.Password))
|
||||||
return operation.Failed(ApplicationMessages.EmptyPassword);
|
return operation.Failed(ApplicationMessages.EmptyPassword);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(command.Username))
|
if (string.IsNullOrWhiteSpace(command.Username))
|
||||||
return operation.Failed(ApplicationMessages.EmptyUsername);
|
return operation.Failed(ApplicationMessages.EmptyUsername);
|
||||||
|
|
||||||
var account = _accountRepository.GetBy(command.Username);
|
var account = _accountRepository.GetBy(command.Username);
|
||||||
var cameraAccount = _cameraAccountRepository.GetBy(command.Username);
|
var cameraAccount = _cameraAccountRepository.GetBy(command.Username);
|
||||||
SubAccount subAccount = _subAccountRepository.GetBy(command.Username);
|
SubAccount subAccount = _subAccountRepository.GetBy(command.Username);
|
||||||
if (account == null && cameraAccount == null && subAccount == null)
|
if (account == null && cameraAccount == null && subAccount == null)
|
||||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||||
|
|
||||||
if (account != null)
|
if (account != null)
|
||||||
{
|
{
|
||||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(account.Password, command.Password);
|
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(account.Password, command.Password);
|
||||||
if (!result.Verified)
|
if (!result.Verified)
|
||||||
@@ -239,14 +405,17 @@ public class AccountApplication : IAccountApplication
|
|||||||
{
|
{
|
||||||
positionValue = null;
|
positionValue = null;
|
||||||
}
|
}
|
||||||
|
var pmUserId = _pmUserQueryService.GetCurrentPmUserIdFromAccountId(account.id).GetAwaiter().GetResult();
|
||||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, positionValue);
|
, account.Username, account.Mobile, account.ProfilePhoto,
|
||||||
|
permissions, account.RoleName, account.AdminAreaPermission,
|
||||||
|
account.ClientAriaPermission, positionValue,0,pmUserId);
|
||||||
|
|
||||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||||
account.IsActiveString == "true")
|
account.IsActiveString == "true")
|
||||||
{
|
{
|
||||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||||
authViewModel.Permissions = clientPermissions;
|
authViewModel.Permissions = clientPermissions;
|
||||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||||
{
|
{
|
||||||
PersonnelCount = x.PersonnelCount,
|
PersonnelCount = x.PersonnelCount,
|
||||||
@@ -255,14 +424,14 @@ public class AccountApplication : IAccountApplication
|
|||||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||||
authViewModel.WorkshopList = workshopList;
|
authViewModel.WorkshopList = workshopList;
|
||||||
if (workshopList.Any())
|
if (workshopList.Any())
|
||||||
{
|
{
|
||||||
var workshop = workshopList.First();
|
var workshop = workshopList.First();
|
||||||
authViewModel.WorkshopName = workshop.Name;
|
authViewModel.WorkshopName = workshop.Name;
|
||||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||||
authViewModel.WorkshopId = workshop.Id;
|
authViewModel.WorkshopId = workshop.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_authHelper.Signin(authViewModel);
|
_authHelper.Signin(authViewModel);
|
||||||
|
|
||||||
@@ -281,7 +450,7 @@ public class AccountApplication : IAccountApplication
|
|||||||
|
|
||||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,cameraAccount.IsActiveSting);
|
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||||
if (cameraAccount.IsActiveSting == "true")
|
if (cameraAccount.IsActiveSting == "true")
|
||||||
{
|
{
|
||||||
_authHelper.CameraSignIn(authViewModel);
|
_authHelper.CameraSignIn(authViewModel);
|
||||||
@@ -291,41 +460,41 @@ public class AccountApplication : IAccountApplication
|
|||||||
{
|
{
|
||||||
idAutoriz = 0;
|
idAutoriz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subAccount != null)
|
if (subAccount != null)
|
||||||
{
|
{
|
||||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(subAccount.Password, command.Password);
|
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(subAccount.Password, command.Password);
|
||||||
if (!result.Verified)
|
if (!result.Verified)
|
||||||
return operation.Failed(ApplicationMessages.WrongUserPass);
|
return operation.Failed(ApplicationMessages.WrongUserPass);
|
||||||
var role = _subAccountRoleRepository.Get(subAccount.SubAccountRoleId);
|
var role = _subAccountRoleRepository.Get(subAccount.SubAccountRoleId);
|
||||||
|
|
||||||
var permissions = role.RolePermissions.Select(x => x.PermissionCode).ToList();
|
var permissions = role.RolePermissions.Select(x => x.PermissionCode).ToList();
|
||||||
var authViewModel = new AuthViewModel(subAccount.AccountId, subAccount.SubAccountRoleId, subAccount.FullName
|
var authViewModel = new AuthViewModel(subAccount.AccountId, subAccount.SubAccountRoleId, subAccount.FullName
|
||||||
, subAccount.Username, subAccount.PhoneNumber, "", permissions, role.Title, "false",
|
, subAccount.Username, subAccount.PhoneNumber, "", permissions, role.Title, "false",
|
||||||
"true", 0, subAccount.id);
|
"true", 0, subAccount.id);
|
||||||
var workshopList = _workshopSubAccountRepository.GetWorkshopsBySubAccountId(subAccount.id);
|
var workshopList = _workshopSubAccountRepository.GetWorkshopsBySubAccountId(subAccount.id);
|
||||||
authViewModel.WorkshopList = workshopList.Select(x => new WorkshopClaim()
|
authViewModel.WorkshopList = workshopList.Select(x => new WorkshopClaim()
|
||||||
{
|
{
|
||||||
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
|
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
|
||||||
Name = x.WorkshopName,
|
Name = x.WorkshopName,
|
||||||
PersonnelCount = x.PersonnelCount,
|
PersonnelCount = x.PersonnelCount,
|
||||||
Id = x.WorkshopId
|
Id = x.WorkshopId
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
if (workshopList.Any())
|
if (workshopList.Any())
|
||||||
{
|
{
|
||||||
var workshop = workshopList.First();
|
var workshop = workshopList.First();
|
||||||
authViewModel.WorkshopName = workshop.WorkshopName;
|
authViewModel.WorkshopName = workshop.WorkshopName;
|
||||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
|
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
|
||||||
authViewModel.WorkshopId = workshop.WorkshopId;
|
authViewModel.WorkshopId = workshop.WorkshopId;
|
||||||
}
|
}
|
||||||
_authHelper.Signin(authViewModel);
|
_authHelper.Signin(authViewModel);
|
||||||
idAutoriz = 2;
|
idAutoriz = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return operation.Succcedded(idAutoriz);
|
return operation.Succcedded(idAutoriz);
|
||||||
}
|
}
|
||||||
public OperationResult LoginWithMobile(long id)
|
public OperationResult LoginWithMobile(long id)
|
||||||
{
|
{
|
||||||
@@ -356,24 +525,24 @@ public class AccountApplication : IAccountApplication
|
|||||||
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
if (account.ClientAriaPermission == "true" && account.AdminAreaPermission == "false" &&
|
||||||
account.IsActiveString == "true")
|
account.IsActiveString == "true")
|
||||||
{
|
{
|
||||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||||
authViewModel.Permissions = clientPermissions;
|
authViewModel.Permissions = clientPermissions;
|
||||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||||
{
|
{
|
||||||
PersonnelCount = x.PersonnelCount,
|
PersonnelCount = x.PersonnelCount,
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
Name = x.WorkshopFullName,
|
Name = x.WorkshopFullName,
|
||||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||||
authViewModel.WorkshopList = workshopList;
|
authViewModel.WorkshopList = workshopList;
|
||||||
if (workshopList.Any())
|
if (workshopList.Any())
|
||||||
{
|
{
|
||||||
var workshop = workshopList.First();
|
var workshop = workshopList.First();
|
||||||
authViewModel.WorkshopName = workshop.Name;
|
authViewModel.WorkshopName = workshop.Name;
|
||||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||||
authViewModel.WorkshopId = workshop.Id;
|
authViewModel.WorkshopId = workshop.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_authHelper.Signin(authViewModel);
|
_authHelper.Signin(authViewModel);
|
||||||
long idAutoriz = 0;
|
long idAutoriz = 0;
|
||||||
@@ -429,7 +598,7 @@ public class AccountApplication : IAccountApplication
|
|||||||
return _accountRepository.GetByUserNameAndId(id, username);
|
return _accountRepository.GetByUserNameAndId(id, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task <OperationResult> SetVerifyCode(string phone, long id)
|
public async Task<OperationResult> SetVerifyCode(string phone, long id)
|
||||||
{
|
{
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
var account = _accountRepository.Get(id);
|
var account = _accountRepository.Get(id);
|
||||||
@@ -443,11 +612,11 @@ public class AccountApplication : IAccountApplication
|
|||||||
_smsService.LoginSend(phone, r);
|
_smsService.LoginSend(phone, r);
|
||||||
|
|
||||||
//TimeSpan delay = TimeSpan.FromSeconds(30);
|
//TimeSpan delay = TimeSpan.FromSeconds(30);
|
||||||
|
|
||||||
await _accountRepository.RemoveCode(id);
|
await _accountRepository.RemoveCode(id);
|
||||||
|
|
||||||
return operation.Succcedded();
|
return operation.Succcedded();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -498,67 +667,67 @@ public class AccountApplication : IAccountApplication
|
|||||||
.Select(x => x.Code)
|
.Select(x => x.Code)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
_authHelper.SignOut();
|
_authHelper.SignOut();
|
||||||
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
|
||||||
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true",null);
|
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true", null);
|
||||||
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
|
||||||
{
|
{
|
||||||
PersonnelCount = x.PersonnelCount,
|
PersonnelCount = x.PersonnelCount,
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
Name = x.WorkshopFullName,
|
Name = x.WorkshopFullName,
|
||||||
Slug = _passwordHasher.SlugHasher(x.Id)
|
Slug = _passwordHasher.SlugHasher(x.Id)
|
||||||
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
}).OrderByDescending(x => x.PersonnelCount).ToList();
|
||||||
|
|
||||||
authViewModel.WorkshopList = workshopList;
|
authViewModel.WorkshopList = workshopList;
|
||||||
|
|
||||||
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
|
||||||
authViewModel.Permissions = clientPermissions;
|
authViewModel.Permissions = clientPermissions;
|
||||||
if (authViewModel.WorkshopList.Any())
|
if (authViewModel.WorkshopList.Any())
|
||||||
{
|
{
|
||||||
var workshop = authViewModel.WorkshopList.First();
|
var workshop = authViewModel.WorkshopList.First();
|
||||||
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
|
||||||
authViewModel.WorkshopName = workshop.Name;
|
authViewModel.WorkshopName = workshop.Name;
|
||||||
authViewModel.WorkshopId = workshop.Id;
|
authViewModel.WorkshopId = workshop.Id;
|
||||||
}
|
}
|
||||||
_authHelper.Signin(authViewModel);
|
_authHelper.Signin(authViewModel);
|
||||||
return operation.Succcedded(2);
|
return operation.Succcedded(2);
|
||||||
}
|
}
|
||||||
public OperationResult DirectCameraLogin(long cameraAccountId)
|
public OperationResult DirectCameraLogin(long cameraAccountId)
|
||||||
{
|
{
|
||||||
var prAcc = _authHelper.CurrentAccountInfo();
|
var prAcc = _authHelper.CurrentAccountInfo();
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
var cameraAccount = _cameraAccountRepository.GetById(cameraAccountId);
|
var cameraAccount = _cameraAccountRepository.GetById(cameraAccountId);
|
||||||
if (cameraAccount == null)
|
if (cameraAccount == null)
|
||||||
return operation.Failed("این اکانت وجود ندارد");
|
return operation.Failed("این اکانت وجود ندارد");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_authHelper.SignOut();
|
_authHelper.SignOut();
|
||||||
|
|
||||||
|
|
||||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||||
if (cameraAccount.IsActiveSting == "true")
|
if (cameraAccount.IsActiveSting == "true")
|
||||||
{
|
{
|
||||||
_authHelper.CameraSignIn(authViewModel);
|
_authHelper.CameraSignIn(authViewModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return operation.Failed("این اکانت غیر فعال شده است");
|
return operation.Failed("این اکانت غیر فعال شده است");
|
||||||
}
|
}
|
||||||
return operation.Succcedded(2);
|
return operation.Succcedded(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
||||||
{
|
{
|
||||||
string fullname = this._accountRepository.GetById(accountId).Fullname;
|
string fullname = this._accountRepository.GetById(accountId).Fullname;
|
||||||
List<WorkshopAccountlistViewModel> source =_accountLeftworkRepository.WorkshopList(accountId);
|
List<WorkshopAccountlistViewModel> source = _accountLeftworkRepository.WorkshopList(accountId);
|
||||||
List<long> userWorkshopIds = source.Select(x => x.WorkshopId).ToList();
|
List<long> userWorkshopIds = source.Select(x => x.WorkshopId).ToList();
|
||||||
List<WorkshopSelectList> allWorkshops = this._accountLeftworkRepository.GetAllWorkshops();
|
List<WorkshopSelectList> allWorkshops = this._accountLeftworkRepository.GetAllWorkshops();
|
||||||
List<AccountViewModel> accountSelectList = this._accountRepository.GetAdminAccountSelectList();
|
List<AccountViewModel> accountSelectList = this._accountRepository.GetAdminAccountSelectList();
|
||||||
@@ -641,65 +810,65 @@ public class AccountApplication : IAccountApplication
|
|||||||
#region Pooya
|
#region Pooya
|
||||||
public OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password, string rePassword)
|
public OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password, string rePassword)
|
||||||
{
|
{
|
||||||
OperationResult op = new();
|
OperationResult op = new();
|
||||||
|
|
||||||
var entity = _accountRepository.Get(accountId);
|
var entity = _accountRepository.Get(accountId);
|
||||||
|
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(rePassword) || !string.IsNullOrWhiteSpace(password))
|
if (!string.IsNullOrWhiteSpace(rePassword) || !string.IsNullOrWhiteSpace(password))
|
||||||
{
|
{
|
||||||
if (rePassword != password)
|
if (rePassword != password)
|
||||||
return op.Failed("تکرار رمز عبور با رمز عبور مطابقت ندارد");
|
return op.Failed("تکرار رمز عبور با رمز عبور مطابقت ندارد");
|
||||||
|
|
||||||
if (password.Length < 8)
|
if (password.Length < 8)
|
||||||
return op.Failed("رمز عبور نمی تواند کمتر از 8 کاراکتر باشد");
|
return op.Failed("رمز عبور نمی تواند کمتر از 8 کاراکتر باشد");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) && string.IsNullOrWhiteSpace(rePassword))
|
if ((string.IsNullOrWhiteSpace(phoneNumber) || entity.Mobile == phoneNumber) && string.IsNullOrWhiteSpace(rePassword))
|
||||||
return op.Failed("چیزی برای تغییر وجود ندارد");
|
return op.Failed("چیزی برای تغییر وجود ندارد");
|
||||||
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(phoneNumber) && entity.Mobile != phoneNumber)
|
if (!string.IsNullOrWhiteSpace(phoneNumber) && entity.Mobile != phoneNumber)
|
||||||
{
|
{
|
||||||
phoneNumber = phoneNumber.Trim();
|
phoneNumber = phoneNumber.Trim();
|
||||||
if (phoneNumber.Length != 11)
|
if (phoneNumber.Length != 11)
|
||||||
return op.Failed("شماره تلفن همراه به درستی وارد نشده است");
|
return op.Failed("شماره تلفن همراه به درستی وارد نشده است");
|
||||||
if (_accountRepository.Exists(x => x.Mobile == phoneNumber && x.id != accountId) ||
|
if (_accountRepository.Exists(x => x.Mobile == phoneNumber && x.id != accountId) ||
|
||||||
_subAccountRepository.Exists(x => x.PhoneNumber == phoneNumber) ||
|
_subAccountRepository.Exists(x => x.PhoneNumber == phoneNumber) ||
|
||||||
_cameraAccountRepository.Exists(x => x.Mobile == phoneNumber))
|
_cameraAccountRepository.Exists(x => x.Mobile == phoneNumber))
|
||||||
return op.Failed("قبلا یک حساب با این شماره ثبت شده است");
|
return op.Failed("قبلا یک حساب با این شماره ثبت شده است");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult ChangePasswordAndPhoneNumber(AccountChangePasswordAndPhoneNumber command)
|
public OperationResult ChangePasswordAndPhoneNumber(AccountChangePasswordAndPhoneNumber command)
|
||||||
{
|
{
|
||||||
OperationResult op = new();
|
OperationResult op = new();
|
||||||
command.PhoneNumber = command.PhoneNumber.Trim();
|
command.PhoneNumber = command.PhoneNumber.Trim();
|
||||||
var entity = _accountRepository.Get(command.AccountId);
|
var entity = _accountRepository.Get(command.AccountId);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||||
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password, command.RePassword);
|
var validationResult = IsPhoneNumberAndPasswordValid(command.AccountId, command.PhoneNumber, command.Password, command.RePassword);
|
||||||
if (validationResult.IsSuccedded == false)
|
if (validationResult.IsSuccedded == false)
|
||||||
return validationResult;
|
return validationResult;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(command.RePassword))
|
if (!string.IsNullOrWhiteSpace(command.RePassword))
|
||||||
{
|
{
|
||||||
|
|
||||||
entity.ChangePassword(_passwordHasher.Hash(command.Password));
|
entity.ChangePassword(_passwordHasher.Hash(command.Password));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(command.PhoneNumber))
|
if (!string.IsNullOrWhiteSpace(command.PhoneNumber))
|
||||||
{
|
{
|
||||||
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto, entity.RoleName);
|
entity.Edit(entity.Fullname, entity.Username, command.PhoneNumber, entity.RoleId, entity.ProfilePhoto, entity.RoleName);
|
||||||
}
|
}
|
||||||
_accountRepository.SaveChanges();
|
_accountRepository.SaveChanges();
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
}
|
}
|
||||||
//public UserClaimsResponseDTO GetClaimsForSignIn(Login command)
|
//public UserClaimsResponseDTO GetClaimsForSignIn(Login command)
|
||||||
//{
|
//{
|
||||||
// var operation = new OperationResult();
|
// var operation = new OperationResult();
|
||||||
@@ -815,12 +984,12 @@ public class AccountApplication : IAccountApplication
|
|||||||
}
|
}
|
||||||
|
|
||||||
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(cameraAccount.Password, request.Password);
|
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(cameraAccount.Password, request.Password);
|
||||||
|
|
||||||
if (!result.Verified)
|
if (!result.Verified)
|
||||||
throw new BadRequestException(ApplicationMessages.WrongUserPass);
|
throw new BadRequestException(ApplicationMessages.WrongUserPass);
|
||||||
|
|
||||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||||
|
|
||||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
|
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
|
||||||
cameraAccount.IsActiveSting);
|
cameraAccount.IsActiveSting);
|
||||||
@@ -829,4 +998,9 @@ public class AccountApplication : IAccountApplication
|
|||||||
|
|
||||||
_authHelper.CameraSignIn(authViewModel);
|
_authHelper.CameraSignIn(authViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<GetPmUserDto> GetPmUserAsync(long accountId)
|
||||||
|
{
|
||||||
|
return await _pmUserQueryService.GetPmUserDataByAccountId(accountId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AccountManagement.Application.Contracts\AccountManagement.Application.Contracts.csproj" />
|
<ProjectReference Include="..\AccountManagement.Application.Contracts\AccountManagement.Application.Contracts.csproj" />
|
||||||
<ProjectReference Include="..\AccountManagement.Domain\AccountManagement.Domain.csproj" />
|
<ProjectReference Include="..\AccountManagement.Domain\AccountManagement.Domain.csproj" />
|
||||||
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
||||||
|
<ProjectReference Include="..\Shared.Contracts\Shared.Contracts.csproj" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using AccountManagement.Application.Contracts.Account;
|
using AccountManagement.Application.Contracts.Account;
|
||||||
using AccountManagement.Application.Contracts.CameraAccount;
|
using AccountManagement.Application.Contracts.CameraAccount;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
using AccountManagement.Application.Contracts.Role;
|
using AccountManagement.Application.Contracts.Role;
|
||||||
using AccountManagement.Domain.RoleAgg;
|
using AccountManagement.Domain.RoleAgg;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Company.Domain._common;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Shared.Contracts.PmRole.Commands;
|
||||||
|
using GetPmRolesDto = Shared.Contracts.PmRole.Queries.GetPmRolesDto;
|
||||||
|
using Role = AccountManagement.Domain.RoleAgg.Role;
|
||||||
|
using Shared.Contracts.PmRole.Queries;
|
||||||
|
|
||||||
namespace AccountManagement.Application;
|
namespace AccountManagement.Application;
|
||||||
|
|
||||||
@@ -9,32 +17,82 @@ public class RoleApplication : IRoleApplication
|
|||||||
{
|
{
|
||||||
private readonly IRoleRepository _roleRepository;
|
private readonly IRoleRepository _roleRepository;
|
||||||
|
|
||||||
public RoleApplication(IRoleRepository roleRepository)
|
private readonly IPmRoleQueryService _pmRoleQueryService;
|
||||||
|
private readonly IPmRoleCommandService _pmRoleCommandService;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork, IPmRoleQueryService pmRoleQueryService, IPmRoleCommandService pmRoleCommandService)
|
||||||
{
|
{
|
||||||
_roleRepository = roleRepository;
|
_roleRepository = roleRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_pmRoleQueryService = pmRoleQueryService;
|
||||||
|
_pmRoleCommandService = pmRoleCommandService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Create(CreateRole command)
|
public async Task<OperationResult> Create(CreateRole command)
|
||||||
{
|
{
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
if (_roleRepository.Exists(x => x.Name == command.Name))
|
if (_roleRepository.Exists(x => x.Name == command.Name))
|
||||||
return operation.Failed(ApplicationMessages.DuplicatedRecord);
|
return operation.Failed(ApplicationMessages.DuplicatedRecord);
|
||||||
var permissions = new List<Permission>();
|
var permissions = command.Permissions.Where(x => x > 0).Select(x => new Permission(x)).ToList();
|
||||||
foreach (var code in command.Permissions)
|
|
||||||
{
|
|
||||||
if (code > 0)
|
|
||||||
{
|
|
||||||
permissions.Add(new Permission(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
|
||||||
var role = new Role(command.Name, permissions);
|
var role = new Role(command.Name, permissions);
|
||||||
|
_unitOfWork.BeginAccountContext();
|
||||||
|
|
||||||
_roleRepository.Create(role);
|
_roleRepository.Create(role);
|
||||||
_roleRepository.SaveChanges();
|
_roleRepository.SaveChanges();
|
||||||
|
|
||||||
|
var pmPermissions = command.PmPermissions.Where(x => x > 0).ToList();
|
||||||
|
if (pmPermissions.Any())
|
||||||
|
{
|
||||||
|
|
||||||
|
var pmRole = new CreatePmRoleDto{ RoleName = command.Name, Permissions = pmPermissions, GozareshgirRoleId = role.id};
|
||||||
|
var res =await _pmRoleCommandService.Create(pmRole);
|
||||||
|
if (!res.Item1)
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//var parameters = new CreateProgramManagerRole
|
||||||
|
//{
|
||||||
|
// RoleName = command.Name,
|
||||||
|
// Permissions = pmPermissions,
|
||||||
|
// GozareshgirRoleId = role.id
|
||||||
|
|
||||||
|
//};
|
||||||
|
|
||||||
|
//var url = "api/role";
|
||||||
|
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||||
|
|
||||||
|
//var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||||
|
// url,
|
||||||
|
// key,
|
||||||
|
// parameters
|
||||||
|
//);
|
||||||
|
|
||||||
|
|
||||||
|
//if (!response.Success)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (!response.Result.isSuccess)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Result.errorMessage);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
||||||
|
_unitOfWork.CommitAccountContext();
|
||||||
return operation.Succcedded();
|
return operation.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Edit(EditRole command)
|
public async Task<OperationResult> Edit(EditRole command)
|
||||||
{
|
{
|
||||||
var operation = new OperationResult();
|
var operation = new OperationResult();
|
||||||
var role = _roleRepository.Get(command.Id);
|
var role = _roleRepository.Get(command.Id);
|
||||||
@@ -47,17 +105,134 @@ public class RoleApplication : IRoleApplication
|
|||||||
//var permissions = new List<Permission>();
|
//var permissions = new List<Permission>();
|
||||||
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
//command.Permissions.ForEach(code => permissions.Add(new Permission(code)));
|
||||||
|
|
||||||
var permissions = new List<Permission>();
|
var permissions = command.Permissions.Where(x => x > 0).Select(x => new Permission(x)).ToList();
|
||||||
foreach (var code in command.Permissions)
|
|
||||||
{
|
|
||||||
if (code > 0)
|
|
||||||
{
|
|
||||||
permissions.Add(new Permission(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_unitOfWork.BeginAccountContext();
|
||||||
role.Edit(command.Name, permissions);
|
role.Edit(command.Name, permissions);
|
||||||
_roleRepository.SaveChanges();
|
_roleRepository.SaveChanges();
|
||||||
|
var key = SecretKeys.ProgramManagerInternalApi;
|
||||||
|
var pmPermissions = command.PmPermissions.Where(x => x > 0).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
//یافتن نقش در پروگرام منیجر
|
||||||
|
//var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||||
|
// "api/role",
|
||||||
|
// key,
|
||||||
|
// new Dictionary<string, object>
|
||||||
|
// {
|
||||||
|
// { "RoleName", "" },
|
||||||
|
|
||||||
|
// { "GozareshgirRoleId", command.Id}
|
||||||
|
// }
|
||||||
|
//);
|
||||||
|
|
||||||
|
|
||||||
|
var pmRoleListResult = await _pmRoleQueryService.GetPmRoleList(command.Id);
|
||||||
|
var pmRoleResult = pmRoleListResult.FirstOrDefault();
|
||||||
|
|
||||||
|
//اگر این نقش در پروگرام منیجر وجود داشت ویرایش کن
|
||||||
|
if (pmRoleResult != null)
|
||||||
|
{
|
||||||
|
var edit = new CreatePmRoleDto { RoleName = command.Name, Permissions = pmPermissions, GozareshgirRoleId = role.id };
|
||||||
|
var res = await _pmRoleCommandService.Edit(edit);
|
||||||
|
if (!res.Item1)
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//var parameters = new CreateProgramManagerRole
|
||||||
|
//{
|
||||||
|
// RoleName = command.Name,
|
||||||
|
// Permissions = pmPermissions,
|
||||||
|
// GozareshgirRoleId = role.id
|
||||||
|
|
||||||
|
//};
|
||||||
|
//var url = "api/role/edit";
|
||||||
|
//var response = InternalApiCaller.PostAsync<CreateProgramManagerRole, ApiResponse>(
|
||||||
|
// url,
|
||||||
|
// key,
|
||||||
|
// parameters
|
||||||
|
//);
|
||||||
|
|
||||||
|
|
||||||
|
//if (!response.Success)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (!response.Result.isSuccess)
|
||||||
|
//{
|
||||||
|
// _unitOfWork.RollbackAccountContext();
|
||||||
|
// return operation.Failed(response.Result.errorMessage);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
else //اگر نقش در پروگرام منیجر وجود نداشت
|
||||||
|
{
|
||||||
|
|
||||||
|
//اگر تیک پرمیشن های پروگرام منیجر زده شده
|
||||||
|
//این نقش را سمت پروگرام منیجر بساز
|
||||||
|
if (pmPermissions.Any())
|
||||||
|
{
|
||||||
|
var pmRole = new CreatePmRoleDto { RoleName = command.Name, Permissions = pmPermissions, GozareshgirRoleId = role.id };
|
||||||
|
var res = await _pmRoleCommandService.Create(pmRole);
|
||||||
|
if (!res.Item1)
|
||||||
|
{
|
||||||
|
_unitOfWork.RollbackAccountContext();
|
||||||
|
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
|
||||||
|
}
|
||||||
|
|
||||||
|
//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();
|
return operation.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,4 +245,23 @@ public class RoleApplication : IRoleApplication
|
|||||||
{
|
{
|
||||||
return _roleRepository.List();
|
return _roleRepository.List();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<SelectList> GetPmRoleList(long? gozareshgirRoleId)
|
||||||
|
{
|
||||||
|
var rolse = await _pmRoleQueryService.GetPmRoleList(gozareshgirRoleId);
|
||||||
|
return new SelectList(rolse, "Id", "RoleName");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetPmRolesDto>> GetPmRoleListToEdit(long? gozareshgirRoleId)
|
||||||
|
{
|
||||||
|
return await _pmRoleQueryService.GetPmRoleList(gozareshgirRoleId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,11 @@ using AccountManagement.Domain.AccountAgg;
|
|||||||
using AccountManagement.Domain.CameraAccountAgg;
|
using AccountManagement.Domain.CameraAccountAgg;
|
||||||
using AccountManagement.Domain.SubAccountAgg;
|
using AccountManagement.Domain.SubAccountAgg;
|
||||||
using AccountManagement.Domain.SubAccountRoleAgg;
|
using AccountManagement.Domain.SubAccountRoleAgg;
|
||||||
using Company.Domain.WorkshopAccountAgg;
|
|
||||||
using Company.Domain.WorkshopSubAccountAgg;
|
using Company.Domain.WorkshopSubAccountAgg;
|
||||||
using CompanyManagment.App.Contracts.Workshop;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AccountManagement.Application
|
namespace AccountManagement.Application
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using AccountManagement.Application.Contracts.TaskSubject;
|
using AccountManagement.Application.Contracts.TaskSubject;
|
||||||
using AccountManagement.Domain.TaskSubjectAgg;
|
using AccountManagement.Domain.TaskSubjectAgg;
|
||||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
|
||||||
|
|
||||||
namespace AccountManagement.Application;
|
namespace AccountManagement.Application;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
||||||
<ProjectReference Include="..\AccountManagement.Application.Contracts\AccountManagement.Application.Contracts.csproj" />
|
<ProjectReference Include="..\AccountManagement.Application.Contracts\AccountManagement.Application.Contracts.csproj" />
|
||||||
|
|||||||
155
AccountManagement.Domain/InternalApiCaller/InternalApiCaller.cs
Normal file
155
AccountManagement.Domain/InternalApiCaller/InternalApiCaller.cs
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace AccountManagement.Domain.InternalApiCaller;
|
||||||
|
|
||||||
|
public class ApiResult<T>
|
||||||
|
{
|
||||||
|
public bool Success { get; set; }
|
||||||
|
public T Result { get; set; }
|
||||||
|
public string Error { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InternalApiCaller
|
||||||
|
{
|
||||||
|
private static string _baseUrl = "";
|
||||||
|
|
||||||
|
public static void SetBaseUrl(string baseUrl)
|
||||||
|
{
|
||||||
|
_baseUrl = baseUrl.TrimEnd('/'); // حذف / اضافی
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///api post متد
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TRequest"></typeparam>
|
||||||
|
/// <typeparam name="TResponse"></typeparam>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="internalKey"></param>
|
||||||
|
/// <param name="body"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ApiResult<TResponse> PostAsync<TRequest, TResponse>(
|
||||||
|
string url,
|
||||||
|
string internalKey,
|
||||||
|
TRequest body
|
||||||
|
)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = new HttpClient();
|
||||||
|
|
||||||
|
// ساخت URL نهایی
|
||||||
|
var finalUrl = $"{_baseUrl}/{url.TrimStart('/')}";
|
||||||
|
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Post, finalUrl);
|
||||||
|
|
||||||
|
request.Headers.Add("X-INTERNAL-KEY", internalKey);
|
||||||
|
|
||||||
|
var json = JsonConvert.SerializeObject(body);
|
||||||
|
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = client.SendAsync(request).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = false,
|
||||||
|
Error = $"HTTP Error: {response.StatusCode}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var text = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||||
|
var deserialized = JsonConvert.DeserializeObject<TResponse>(text);
|
||||||
|
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
Result = deserialized
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = false,
|
||||||
|
Error = ex.Message
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Api Get متد
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TResponse"></typeparam>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="internalKey"></param>
|
||||||
|
/// <param name="parameters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ApiResult<TResponse> GetAsync<TResponse>(
|
||||||
|
string url,
|
||||||
|
string internalKey,
|
||||||
|
Dictionary<string, object> parameters = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (parameters != null && parameters.Any())
|
||||||
|
{
|
||||||
|
var query = string.Join("&",
|
||||||
|
parameters
|
||||||
|
.Where(p => p.Value != null)
|
||||||
|
.Select(p => $"{p.Key}={p.Value}")
|
||||||
|
);
|
||||||
|
|
||||||
|
url += url.Contains("?") ? "&" + query : "?" + query;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ساخت URL نهایی
|
||||||
|
var finalUrl = $"{_baseUrl}/{url.TrimStart('/')}";
|
||||||
|
|
||||||
|
var client = new HttpClient();
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Get, finalUrl);
|
||||||
|
|
||||||
|
request.Headers.Add("X-INTERNAL-KEY", internalKey);
|
||||||
|
|
||||||
|
var response = client.SendAsync(request).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = false,
|
||||||
|
Error = $"HTTP Error: {response.StatusCode}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var text = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||||
|
var deserialized = JsonConvert.DeserializeObject<TResponse>(text);
|
||||||
|
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
Result = deserialized
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new ApiResult<TResponse>
|
||||||
|
{
|
||||||
|
Success = false,
|
||||||
|
Error = ex.Message
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Azure.Identity" Version="1.17.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -18,6 +20,10 @@
|
|||||||
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Services\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Mappings\BugReportMapping.cs" />
|
<Compile Remove="Mappings\BugReportMapping.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class addprogrammangerbooinaccount : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsProgramManagerUser",
|
||||||
|
table: "Accounts",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsProgramManagerUser",
|
||||||
|
table: "Accounts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class romoveIsProgramManagerUserFromAccount : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsProgramManagerUser",
|
||||||
|
table: "Accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsProgramManagerUser",
|
||||||
|
table: "Accounts",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "10.0.1")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
@@ -377,6 +377,87 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
|||||||
b.ToTable("Medias", (string)null);
|
b.ToTable("Medias", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountManagement.Domain.PmDomains.PmRoleAgg.PmRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreationDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<long?>("GozareshgirRoleId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("RoleName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.HasKey("id");
|
||||||
|
|
||||||
|
b.ToTable("PmRoles", null, t =>
|
||||||
|
{
|
||||||
|
t.ExcludeFromMigrations();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountManagement.Domain.PmDomains.PmUserAgg.PmUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
|
b.Property<long?>("AccountId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreationDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(150)
|
||||||
|
.HasColumnType("nvarchar(150)");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Mobile")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("nvarchar(20)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("nvarchar(1000)");
|
||||||
|
|
||||||
|
b.Property<string>("ProfilePhotoPath")
|
||||||
|
.HasMaxLength(500)
|
||||||
|
.HasColumnType("nvarchar(500)");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<string>("VerifyCode")
|
||||||
|
.HasMaxLength(10)
|
||||||
|
.HasColumnType("nvarchar(10)");
|
||||||
|
|
||||||
|
b.HasKey("id");
|
||||||
|
|
||||||
|
b.ToTable("Users", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b =>
|
modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("id")
|
b.Property<long>("id")
|
||||||
@@ -1001,6 +1082,71 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
|||||||
b.Navigation("Media");
|
b.Navigation("Media");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountManagement.Domain.PmDomains.PmRoleAgg.PmRole", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("AccountManagement.Domain.PmDomains.PmPermissionAgg.PmPermission", "PmPermission", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("Id"));
|
||||||
|
|
||||||
|
b1.Property<int>("Code")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b1.Property<long>("Roleid")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b1.HasKey("Id");
|
||||||
|
|
||||||
|
b1.HasIndex("Roleid");
|
||||||
|
|
||||||
|
b1.ToTable("PmRolePermissions", null, t =>
|
||||||
|
{
|
||||||
|
t.ExcludeFromMigrations();
|
||||||
|
});
|
||||||
|
|
||||||
|
b1.WithOwner("Role")
|
||||||
|
.HasForeignKey("Roleid");
|
||||||
|
|
||||||
|
b1.Navigation("Role");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("PmPermission");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AccountManagement.Domain.PmDomains.PmUserAgg.PmUser", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("AccountManagement.Domain.PmDomains.PmRoleUserAgg.PmRoleUser", "RoleUser", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("Id"));
|
||||||
|
|
||||||
|
b1.Property<long>("RoleId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b1.Property<long>("Userid")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b1.HasKey("Id");
|
||||||
|
|
||||||
|
b1.HasIndex("Userid");
|
||||||
|
|
||||||
|
b1.ToTable("RoleUsers", (string)null);
|
||||||
|
|
||||||
|
b1.WithOwner("User")
|
||||||
|
.HasForeignKey("Userid");
|
||||||
|
|
||||||
|
b1.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("RoleUser");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b =>
|
modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b =>
|
||||||
{
|
{
|
||||||
b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 =>
|
b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 =>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<AssemblyName>BackgroundInstitutionContract.Task</AssemblyName>
|
<AssemblyName>BackgroundInstitutionContract.Task</AssemblyName>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -92,12 +92,17 @@ public class CameraBugReport
|
|||||||
public string StackTrace { get; private set; }
|
public string StackTrace { get; private set; }
|
||||||
|
|
||||||
[BsonElement("status")]
|
[BsonElement("status")]
|
||||||
|
[BsonRepresentation(MongoDB.Bson.BsonType.String)]
|
||||||
public CameraBugReportStatus Status { get; private set; }
|
public CameraBugReportStatus Status { get; private set; }
|
||||||
|
|
||||||
[BsonElement("priority")]
|
[BsonElement("priority")]
|
||||||
|
[BsonRepresentation(MongoDB.Bson.BsonType.String)]
|
||||||
|
|
||||||
public CameraBugPriority Priority { get; private set; }
|
public CameraBugPriority Priority { get; private set; }
|
||||||
|
|
||||||
[BsonElement("type")]
|
[BsonElement("type")]
|
||||||
|
[BsonRepresentation(MongoDB.Bson.BsonType.String)]
|
||||||
|
|
||||||
public CameraBugReportType Type { get; private set; }
|
public CameraBugReportType Type { get; private set; }
|
||||||
|
|
||||||
[BsonElement("flavor")]
|
[BsonElement("flavor")]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -16,10 +16,15 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="CheckoutAgg\ValueObjects\" />
|
<Folder Include="CheckoutAgg\ValueObjects\" />
|
||||||
|
<Folder Include="_common\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MongoDB.Bson" Version="3.5.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
|
||||||
|
<PackageReference Include="MongoDB.Bson" Version="3.5.2" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
8
Company.Domain/_common/IUnitOfWork.cs
Normal file
8
Company.Domain/_common/IUnitOfWork.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Company.Domain._common;
|
||||||
|
|
||||||
|
public interface IUnitOfWork
|
||||||
|
{
|
||||||
|
void BeginAccountContext();
|
||||||
|
void CommitAccountContext();
|
||||||
|
void RollbackAccountContext();
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="EPPlus" Version="7.5.2" />
|
<PackageReference Include="Azure.Identity" Version="1.17.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
|
<PackageReference Include="EPPlus" Version="8.4.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AccountMangement.Infrastructure.EFCore\AccountMangement.Infrastructure.EFCore.csproj" />
|
<ProjectReference Include="..\AccountMangement.Infrastructure.EFCore\AccountMangement.Infrastructure.EFCore.csproj" />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MongoDB.Driver" Version="3.5.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
<PackageReference Include="MongoDB.Driver" Version="3.5.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
|
||||||
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AndroidXml" Version="1.1.24" />
|
<PackageReference Include="AndroidXml" Version="1.1.24" />
|
||||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
<PackageReference Include="Azure.Identity" Version="1.17.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Azure.Identity" Version="1.17.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="16.11.230815" />
|
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="18.1.1" />
|
||||||
<PackageReference Include="MongoDB.Driver" Version="3.5.0" />
|
<PackageReference Include="MongoDB.Driver" Version="3.5.2" />
|
||||||
<PackageReference Include="Parbad.Gateway.Sepehr" Version="1.7.0" />
|
<PackageReference Include="Parbad.Gateway.Sepehr" Version="1.7.0" />
|
||||||
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace CompanyManagment.EFCore.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class addcamerabugreport : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CameraBugReports",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(type: "bigint", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
StackTrace = table.Column<string>(type: "ntext", nullable: true),
|
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Priority = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Type = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Flavor = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
LastUpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
InstallTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
PackageName = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: true),
|
|
||||||
BuildNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
AppVersion = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
NetworkType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
IsCharging = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
BatteryLevel = table.Column<int>(type: "int", nullable: false),
|
|
||||||
StorageInMB = table.Column<int>(type: "int", nullable: false),
|
|
||||||
MemoryInMB = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ScreenResolution = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
DeviceId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
|
||||||
Manufacturer = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
||||||
Platform = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
OsVersion = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
||||||
DeviceModel = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
||||||
AccountId = table.Column<long>(type: "bigint", nullable: true),
|
|
||||||
UserEmail = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "ntext", nullable: false),
|
|
||||||
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CameraBugReports", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CameraBugReportLogs",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(type: "bigint", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
CameraBugReportId = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
Message = table.Column<string>(type: "ntext", nullable: false),
|
|
||||||
Timestamp = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CameraBugReportLogs", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CameraBugReportLogs_CameraBugReports_CameraBugReportId",
|
|
||||||
column: x => x.CameraBugReportId,
|
|
||||||
principalTable: "CameraBugReports",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CameraBugReportScreenshots",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(type: "bigint", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
CameraBugReportId = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
Base64Data = table.Column<string>(type: "ntext", nullable: false),
|
|
||||||
FileName = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
|
||||||
UploadDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CameraBugReportScreenshots", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CameraBugReportScreenshots_CameraBugReports_CameraBugReportId",
|
|
||||||
column: x => x.CameraBugReportId,
|
|
||||||
principalTable: "CameraBugReports",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_CameraBugReportLogs_CameraBugReportId",
|
|
||||||
table: "CameraBugReportLogs",
|
|
||||||
column: "CameraBugReportId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_CameraBugReportScreenshots_CameraBugReportId",
|
|
||||||
table: "CameraBugReportScreenshots",
|
|
||||||
column: "CameraBugReportId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CameraBugReportLogs");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CameraBugReportScreenshots");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CameraBugReports");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,15 +13,15 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace CompanyManagment.EFCore.Migrations
|
namespace CompanyManagment.EFCore.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(CompanyContext))]
|
[DbContext(typeof(CompanyContext))]
|
||||||
[Migration("20251207125001_add camera bug report")]
|
[Migration("20251213184424_testmig")]
|
||||||
partial class addcamerabugreport
|
partial class testmig
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "10.0.1")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
@@ -313,44 +313,36 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReport", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReport", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
|
||||||
|
|
||||||
b.Property<long?>("AccountId")
|
b.Property<long?>("AccountId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.Property<string>("AppVersion")
|
b.Property<string>("AppVersion")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<int>("BatteryLevel")
|
b.Property<int>("BatteryLevel")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("BuildNumber")
|
b.Property<string>("BuildNumber")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceId")
|
b.Property<string>("DeviceId")
|
||||||
.HasMaxLength(200)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(200)");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceModel")
|
b.Property<string>("DeviceModel")
|
||||||
.HasMaxLength(100)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<string>("Flavor")
|
b.Property<string>("Flavor")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("InstallTime")
|
b.Property<DateTime>("InstallTime")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -362,37 +354,31 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Manufacturer")
|
b.Property<string>("Manufacturer")
|
||||||
.HasMaxLength(100)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<int>("MemoryInMB")
|
b.Property<int>("MemoryInMB")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("NetworkType")
|
b.Property<string>("NetworkType")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("OsVersion")
|
b.Property<string>("OsVersion")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("PackageName")
|
b.Property<string>("PackageName")
|
||||||
.HasMaxLength(150)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(150)");
|
|
||||||
|
|
||||||
b.Property<string>("Platform")
|
b.Property<string>("Platform")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<int>("Priority")
|
b.Property<int>("Priority")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("ScreenResolution")
|
b.Property<string>("ScreenResolution")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("StackTrace")
|
b.Property<string>("StackTrace")
|
||||||
.HasColumnType("ntext");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
@@ -401,9 +387,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Title")
|
b.Property<string>("Title")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasMaxLength(200)
|
|
||||||
.HasColumnType("nvarchar(200)");
|
|
||||||
|
|
||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
@@ -412,13 +396,11 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("UserEmail")
|
b.Property<string>("UserEmail")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasMaxLength(150)
|
|
||||||
.HasColumnType("nvarchar(150)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("CameraBugReports", (string)null);
|
b.ToTable("CameraBugReports");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
||||||
@@ -429,15 +411,14 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
b.Property<long>("CameraBugReportId")
|
b.Property<Guid?>("CameraBugReportId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Message")
|
b.Property<string>("Message")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
b.Property<DateTime>("Timestamp")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -446,7 +427,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CameraBugReportId");
|
b.HasIndex("CameraBugReportId");
|
||||||
|
|
||||||
b.ToTable("CameraBugReportLogs", (string)null);
|
b.ToTable("CameraBugReportLogs");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
||||||
@@ -458,18 +439,16 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
b.Property<string>("Base64Data")
|
b.Property<string>("Base64Data")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<long>("CameraBugReportId")
|
b.Property<Guid?>("CameraBugReportId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("FileName")
|
b.Property<string>("FileName")
|
||||||
.HasMaxLength(255)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(255)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UploadDate")
|
b.Property<DateTime>("UploadDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -478,7 +457,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CameraBugReportId");
|
b.HasIndex("CameraBugReportId");
|
||||||
|
|
||||||
b.ToTable("CameraBugReportScreenshots", (string)null);
|
b.ToTable("CameraBugReportScreenshots");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
||||||
@@ -4180,7 +4159,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasMaxLength(4)
|
.HasMaxLength(4)
|
||||||
.HasColumnType("nvarchar(4)");
|
.HasColumnType("nvarchar(4)");
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -4202,7 +4181,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("nvarchar(50)");
|
.HasColumnType("nvarchar(50)");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -4219,7 +4198,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("nvarchar(50)");
|
.HasColumnType("nvarchar(50)");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -7332,24 +7311,16 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", "CameraBugReport")
|
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", null)
|
||||||
.WithMany("Logs")
|
.WithMany("Logs")
|
||||||
.HasForeignKey("CameraBugReportId")
|
.HasForeignKey("CameraBugReportId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("CameraBugReport");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", "CameraBugReport")
|
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", null)
|
||||||
.WithMany("Screenshots")
|
.WithMany("Screenshots")
|
||||||
.HasForeignKey("CameraBugReportId")
|
.HasForeignKey("CameraBugReportId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("CameraBugReport");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
||||||
23
CompanyManagment.EFCore/Migrations/20251213184424_testmig.cs
Normal file
23
CompanyManagment.EFCore/Migrations/20251213184424_testmig.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CompanyManagment.EFCore.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class testmig : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "10.0.1")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
@@ -310,44 +310,36 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReport", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReport", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
|
||||||
|
|
||||||
b.Property<long?>("AccountId")
|
b.Property<long?>("AccountId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.Property<string>("AppVersion")
|
b.Property<string>("AppVersion")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<int>("BatteryLevel")
|
b.Property<int>("BatteryLevel")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("BuildNumber")
|
b.Property<string>("BuildNumber")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceId")
|
b.Property<string>("DeviceId")
|
||||||
.HasMaxLength(200)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(200)");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceModel")
|
b.Property<string>("DeviceModel")
|
||||||
.HasMaxLength(100)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<string>("Flavor")
|
b.Property<string>("Flavor")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("InstallTime")
|
b.Property<DateTime>("InstallTime")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -359,37 +351,31 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Manufacturer")
|
b.Property<string>("Manufacturer")
|
||||||
.HasMaxLength(100)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<int>("MemoryInMB")
|
b.Property<int>("MemoryInMB")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("NetworkType")
|
b.Property<string>("NetworkType")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("OsVersion")
|
b.Property<string>("OsVersion")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("PackageName")
|
b.Property<string>("PackageName")
|
||||||
.HasMaxLength(150)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(150)");
|
|
||||||
|
|
||||||
b.Property<string>("Platform")
|
b.Property<string>("Platform")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<int>("Priority")
|
b.Property<int>("Priority")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("ScreenResolution")
|
b.Property<string>("ScreenResolution")
|
||||||
.HasMaxLength(50)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(50)");
|
|
||||||
|
|
||||||
b.Property<string>("StackTrace")
|
b.Property<string>("StackTrace")
|
||||||
.HasColumnType("ntext");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
@@ -398,9 +384,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Title")
|
b.Property<string>("Title")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasMaxLength(200)
|
|
||||||
.HasColumnType("nvarchar(200)");
|
|
||||||
|
|
||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
@@ -409,13 +393,11 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("UserEmail")
|
b.Property<string>("UserEmail")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasMaxLength(150)
|
|
||||||
.HasColumnType("nvarchar(150)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("CameraBugReports", (string)null);
|
b.ToTable("CameraBugReports");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
||||||
@@ -426,15 +408,14 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
b.Property<long>("CameraBugReportId")
|
b.Property<Guid?>("CameraBugReportId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Message")
|
b.Property<string>("Message")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
b.Property<DateTime>("Timestamp")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -443,7 +424,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CameraBugReportId");
|
b.HasIndex("CameraBugReportId");
|
||||||
|
|
||||||
b.ToTable("CameraBugReportLogs", (string)null);
|
b.ToTable("CameraBugReportLogs");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
||||||
@@ -455,18 +436,16 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||||
|
|
||||||
b.Property<string>("Base64Data")
|
b.Property<string>("Base64Data")
|
||||||
.IsRequired()
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("ntext");
|
|
||||||
|
|
||||||
b.Property<long>("CameraBugReportId")
|
b.Property<Guid?>("CameraBugReportId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("FileName")
|
b.Property<string>("FileName")
|
||||||
.HasMaxLength(255)
|
.HasColumnType("nvarchar(max)");
|
||||||
.HasColumnType("nvarchar(255)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UploadDate")
|
b.Property<DateTime>("UploadDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
@@ -475,7 +454,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CameraBugReportId");
|
b.HasIndex("CameraBugReportId");
|
||||||
|
|
||||||
b.ToTable("CameraBugReportScreenshots", (string)null);
|
b.ToTable("CameraBugReportScreenshots");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
||||||
@@ -4177,7 +4156,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasMaxLength(4)
|
.HasMaxLength(4)
|
||||||
.HasColumnType("nvarchar(4)");
|
.HasColumnType("nvarchar(4)");
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -4199,7 +4178,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("nvarchar(50)");
|
.HasColumnType("nvarchar(50)");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -4216,7 +4195,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasColumnType("nvarchar(50)");
|
.HasColumnType("nvarchar(50)");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.ComplexProperty<Dictionary<string, object>>("Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
|
b.ComplexProperty(typeof(Dictionary<string, object>), "Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
|
||||||
{
|
{
|
||||||
b1.IsRequired();
|
b1.IsRequired();
|
||||||
|
|
||||||
@@ -7329,24 +7308,16 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportLog", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", "CameraBugReport")
|
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", null)
|
||||||
.WithMany("Logs")
|
.WithMany("Logs")
|
||||||
.HasForeignKey("CameraBugReportId")
|
.HasForeignKey("CameraBugReportId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("CameraBugReport");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
modelBuilder.Entity("Company.Domain.CameraBugReportAgg.CameraBugReportScreenshot", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", "CameraBugReport")
|
b.HasOne("Company.Domain.CameraBugReportAgg.CameraBugReport", null)
|
||||||
.WithMany("Screenshots")
|
.WithMany("Screenshots")
|
||||||
.HasForeignKey("CameraBugReportId")
|
.HasForeignKey("CameraBugReportId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("CameraBugReport");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// چیک میکند که آیا پرسنل در سال و ماه درخواستی در این کارگاه فیش حقوقی دارد یا خیر
|
/// چک میکند که آیا پرسنل در سال و ماه درخواستی در این کارگاه فیش حقوقی دارد یا خیر
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="workshopId"></param>
|
/// <param name="workshopId"></param>
|
||||||
/// <param name="employeId"></param>
|
/// <param name="employeId"></param>
|
||||||
@@ -74,12 +74,21 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|||||||
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
|
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
|
||||||
{
|
{
|
||||||
var farisMonthName = Tools.ToFarsiMonthByNumber(month);
|
var farisMonthName = Tools.ToFarsiMonthByNumber(month);
|
||||||
|
|
||||||
var res = _context.CheckoutSet.FirstOrDefault(x =>
|
var res = _context.CheckoutSet.FirstOrDefault(x =>
|
||||||
x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName &&
|
x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName &&
|
||||||
x.IsActiveString == "true");
|
x.IsActiveString == "true");
|
||||||
if (res == null)
|
if (res == null)
|
||||||
return (false, 0, 0,0,0,0,0);
|
{
|
||||||
|
var checkLeftDate = ($"{year}/{month}/01").ToGeorgianDateTime();
|
||||||
|
var hasLeftwork = _context.LeftWorkList.Any(x =>
|
||||||
|
x.EmployeeId == employeId && x.WorkshopId == workshopId && x.LeftWorkDate == checkLeftDate);
|
||||||
|
if(hasLeftwork)
|
||||||
|
return (true, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
return (false, 0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay);
|
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2860,7 +2860,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
|||||||
var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList)
|
var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList)
|
||||||
.Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId &&
|
.Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId &&
|
||||||
x.ContractEnd >= startDate && x.ContarctStart <= endDate).ToList();
|
x.ContractEnd >= startDate && x.ContarctStart <= endDate).ToList();
|
||||||
|
var isWorkshopStaticCheckout = _context.Workshops.FirstOrDefault(x => x.id == workshopId)!.IsStaticCheckout;
|
||||||
int mandatoryDays = 0;
|
int mandatoryDays = 0;
|
||||||
double allCanToLeave = 0;
|
double allCanToLeave = 0;
|
||||||
double canToLeave = 0;
|
double canToLeave = 0;
|
||||||
@@ -2894,7 +2894,8 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
|||||||
|
|
||||||
var rollCallTotalHoures = GetTotalWorkingHoursIfHasRollCall(employeeId, workshopId,
|
var rollCallTotalHoures = GetTotalWorkingHoursIfHasRollCall(employeeId, workshopId,
|
||||||
contract.ContarctStart.Date, contract.ContractEnd.Date);
|
contract.ContarctStart.Date, contract.ContractEnd.Date);
|
||||||
if (rollCallTotalHoures.hasRollCall)
|
|
||||||
|
if (rollCallTotalHoures.hasRollCall && !isWorkshopStaticCheckout)
|
||||||
{
|
{
|
||||||
totalWorkingHours = rollCallTotalHoures.WorkingTotalHours;
|
totalWorkingHours = rollCallTotalHoures.WorkingTotalHours;
|
||||||
}
|
}
|
||||||
@@ -3375,6 +3376,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
|||||||
var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList)
|
var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList)
|
||||||
.Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId &&
|
.Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId &&
|
||||||
x.ContractEnd >= startDate && x.ContarctStart <= endDate).OrderBy(x => x.ContarctStart).ToList();
|
x.ContractEnd >= startDate && x.ContarctStart <= endDate).OrderBy(x => x.ContarctStart).ToList();
|
||||||
|
var isWorkshopStaticCheckout = _context.Workshops.FirstOrDefault(x => x.id == workshopId)!.IsStaticCheckout;
|
||||||
double canToLeave = 0;
|
double canToLeave = 0;
|
||||||
int contractCounter = 0;
|
int contractCounter = 0;
|
||||||
foreach (var contract in allContractsBetween)
|
foreach (var contract in allContractsBetween)
|
||||||
@@ -3407,7 +3409,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
|||||||
|
|
||||||
var rollCallTotalHoures = GetTotalWorkingHoursIfHasRollCall(employeeId, workshopId,
|
var rollCallTotalHoures = GetTotalWorkingHoursIfHasRollCall(employeeId, workshopId,
|
||||||
contract.ContarctStart.Date, contract.ContractEnd.Date);
|
contract.ContarctStart.Date, contract.ContractEnd.Date);
|
||||||
if (rollCallTotalHoures.hasRollCall)
|
if (rollCallTotalHoures.hasRollCall && !isWorkshopStaticCheckout)
|
||||||
{
|
{
|
||||||
totalWorkingHours = rollCallTotalHoures.WorkingTotalHours;
|
totalWorkingHours = rollCallTotalHoures.WorkingTotalHours;
|
||||||
}
|
}
|
||||||
|
|||||||
32
CompanyManagment.EFCore/Services/HolidayQueryService.cs
Normal file
32
CompanyManagment.EFCore/Services/HolidayQueryService.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PersianTools.Core;
|
||||||
|
using Shared.Contracts.Holidays;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CompanyManagment.EFCore.Services;
|
||||||
|
|
||||||
|
public class HolidayQueryService : IHolidayQueryService
|
||||||
|
{
|
||||||
|
private readonly CompanyContext _context;
|
||||||
|
|
||||||
|
public HolidayQueryService(CompanyContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<HolidayDto>> GetHolidaysInDates(DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
return await _context.HolidayItems.Where(x => x.Holidaydate >= startDate && x.Holidaydate <= endDate).Select(x=> new HolidayDto()
|
||||||
|
{
|
||||||
|
Holidaydate = x.Holidaydate,
|
||||||
|
HolidayId = x.id,
|
||||||
|
HolidayYear = x.HolidayYear
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
31
CompanyManagment.EFCore/_common/UnitOfWork.cs
Normal file
31
CompanyManagment.EFCore/_common/UnitOfWork.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using AccountMangement.Infrastructure.EFCore;
|
||||||
|
using Company.Domain._common;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
|
|
||||||
|
namespace CompanyManagment.EFCore._common;
|
||||||
|
|
||||||
|
public class UnitOfWork : IUnitOfWork
|
||||||
|
{
|
||||||
|
private readonly AccountContext _context;
|
||||||
|
private IDbContextTransaction _transaction;
|
||||||
|
|
||||||
|
public UnitOfWork(AccountContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeginAccountContext()
|
||||||
|
{
|
||||||
|
_transaction = _context.Database.BeginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CommitAccountContext()
|
||||||
|
{
|
||||||
|
_transaction?.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RollbackAccountContext()
|
||||||
|
{
|
||||||
|
_transaction?.Rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -88,6 +88,26 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyManagement.Infrastru
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundInstitutionContract.Task", "BackgroundInstitutionContract\BackgroundInstitutionContract.Task\BackgroundInstitutionContract.Task.csproj", "{F78FBB92-294B-88BA-168D-F0C578B0D7D6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundInstitutionContract.Task", "BackgroundInstitutionContract\BackgroundInstitutionContract.Task\BackgroundInstitutionContract.Task.csproj", "{F78FBB92-294B-88BA-168D-F0C578B0D7D6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProgramManager", "ProgramManager", "{67AFF7B6-4C4F-464C-A90D-9BDB644D83A9}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{48F6F6A5-7340-42F8-9216-BEB7A4B7D5A1}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{9D85672B-D48E-40B5-9804-0CE220E0E64C}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{D74D1E3B-3BE3-47EE-9914-785A8AD536E5}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{C0AE9368-D4E7-450B-9713-929D319DE690}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GozareshgirProgramManager.Application", "ProgramManager\src\Application\GozareshgirProgramManager.Application\GozareshgirProgramManager.Application.csproj", "{B57EB542-C028-4A77-9386-9DFF1E60FDCB}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GozareshgirProgramManager.Domain", "ProgramManager\src\Domain\GozareshgirProgramManager.Domain\GozareshgirProgramManager.Domain.csproj", "{D2B4F1D7-6336-4B30-910C-219F4119303F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GozareshgirProgramManager.Infrastructure", "ProgramManager\src\Infrastructure\GozareshgirProgramManager.Infrastructure\GozareshgirProgramManager.Infrastructure.csproj", "{408281FE-615F-4CBE-BD95-2E86F5ACC6C3}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.Contracts", "Shared.Contracts\Shared.Contracts.csproj", "{08B234B6-783B-44E9-9961-4F97EAD16308}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{F61F77F5-9B14-49CC-870B-1C61D2636586}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -198,6 +218,22 @@ Global
|
|||||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B57EB542-C028-4A77-9386-9DFF1E60FDCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B57EB542-C028-4A77-9386-9DFF1E60FDCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B57EB542-C028-4A77-9386-9DFF1E60FDCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B57EB542-C028-4A77-9386-9DFF1E60FDCB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D2B4F1D7-6336-4B30-910C-219F4119303F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D2B4F1D7-6336-4B30-910C-219F4119303F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D2B4F1D7-6336-4B30-910C-219F4119303F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D2B4F1D7-6336-4B30-910C-219F4119303F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{408281FE-615F-4CBE-BD95-2E86F5ACC6C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{408281FE-615F-4CBE-BD95-2E86F5ACC6C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{408281FE-615F-4CBE-BD95-2E86F5ACC6C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{408281FE-615F-4CBE-BD95-2E86F5ACC6C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -234,6 +270,14 @@ Global
|
|||||||
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2} = {86921E1B-2AFA-4B8A-9403-EE16D58B5B26}
|
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2} = {86921E1B-2AFA-4B8A-9403-EE16D58B5B26}
|
||||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
{97E148FA-3C36-40DD-B121-D90C1C0F3B47} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
||||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
{F78FBB92-294B-88BA-168D-F0C578B0D7D6} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
||||||
|
{48F6F6A5-7340-42F8-9216-BEB7A4B7D5A1} = {67AFF7B6-4C4F-464C-A90D-9BDB644D83A9}
|
||||||
|
{9D85672B-D48E-40B5-9804-0CE220E0E64C} = {48F6F6A5-7340-42F8-9216-BEB7A4B7D5A1}
|
||||||
|
{D74D1E3B-3BE3-47EE-9914-785A8AD536E5} = {48F6F6A5-7340-42F8-9216-BEB7A4B7D5A1}
|
||||||
|
{C0AE9368-D4E7-450B-9713-929D319DE690} = {48F6F6A5-7340-42F8-9216-BEB7A4B7D5A1}
|
||||||
|
{B57EB542-C028-4A77-9386-9DFF1E60FDCB} = {9D85672B-D48E-40B5-9804-0CE220E0E64C}
|
||||||
|
{D2B4F1D7-6336-4B30-910C-219F4119303F} = {D74D1E3B-3BE3-47EE-9914-785A8AD536E5}
|
||||||
|
{408281FE-615F-4CBE-BD95-2E86F5ACC6C3} = {C0AE9368-D4E7-450B-9713-929D319DE690}
|
||||||
|
{08B234B6-783B-44E9-9961-4F97EAD16308} = {F61F77F5-9B14-49CC-870B-1C61D2636586}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {E6CFB3A7-A7C8-4E82-8F06-F750408F0BA9}
|
SolutionGuid = {E6CFB3A7-A7C8-4E82-8F06-F750408F0BA9}
|
||||||
|
|||||||
@@ -1,18 +1,44 @@
|
|||||||
using System;
|
using _0_Framework.Application.FaceEmbedding;
|
||||||
using _0_Framework.Application.UID;
|
using _0_Framework.Application.UID;
|
||||||
|
using _0_Framework.Infrastructure;
|
||||||
|
using _0_Framework.InfraStructure;
|
||||||
using Company.Application.Contracts.AuthorizedBankDetails;
|
using Company.Application.Contracts.AuthorizedBankDetails;
|
||||||
|
using Company.Domain._common;
|
||||||
|
using Company.Domain.AdminMonthlyOverviewAgg;
|
||||||
|
using Company.Domain.AndroidApkVersionAgg;
|
||||||
|
using Company.Domain.AuthorizedBankDetailsAgg;
|
||||||
|
using Company.Domain.AuthorizedPersonAgg;
|
||||||
|
using Company.Domain.BankAgg;
|
||||||
using Company.Domain.BillAgg;
|
using Company.Domain.BillAgg;
|
||||||
using Company.Domain.Board;
|
using Company.Domain.Board;
|
||||||
using Company.Domain.ChapterAgg;
|
using Company.Domain.ChapterAgg;
|
||||||
using Company.Domain.CheckoutAgg;
|
using Company.Domain.CheckoutAgg;
|
||||||
using Company.Domain.ClassifiedSalaryAgg;
|
using Company.Domain.ClassifiedSalaryAgg;
|
||||||
using Company.Domain.Contact2Agg;
|
using Company.Domain.Contact2Agg;
|
||||||
using Company.Domain.CrossJobAgg;
|
using Company.Domain.ContactUsAgg;
|
||||||
using Company.Domain.CrossJobGuildAgg;
|
|
||||||
using Company.Domain.ContarctingPartyAgg;
|
using Company.Domain.ContarctingPartyAgg;
|
||||||
using Company.Domain.ContractAgg;
|
using Company.Domain.ContractAgg;
|
||||||
|
using Company.Domain.ContractingPartyBankAccountsAgg;
|
||||||
|
using Company.Domain.CrossJobAgg;
|
||||||
|
using Company.Domain.CrossJobGuildAgg;
|
||||||
|
using Company.Domain.CrossJobItemsAgg;
|
||||||
|
using Company.Domain.CustomizeCheckoutAgg;
|
||||||
|
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||||
|
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||||
|
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||||
|
using Company.Domain.CustomizeWorkshopSettingsAgg;
|
||||||
|
using Company.Domain.DateSalaryAgg;
|
||||||
|
using Company.Domain.DateSalaryItemAgg;
|
||||||
using Company.Domain.EmployeeAgg;
|
using Company.Domain.EmployeeAgg;
|
||||||
|
using Company.Domain.EmployeeAuthorizeTempAgg;
|
||||||
|
using Company.Domain.EmployeeBankInformationAgg;
|
||||||
using Company.Domain.EmployeeChildrenAgg;
|
using Company.Domain.EmployeeChildrenAgg;
|
||||||
|
using Company.Domain.EmployeeClientTempAgg;
|
||||||
|
using Company.Domain.EmployeeComputeOptionsAgg;
|
||||||
|
using Company.Domain.EmployeeDocumentItemAgg;
|
||||||
|
using Company.Domain.EmployeeDocumentsAdminSelectionAgg;
|
||||||
|
using Company.Domain.EmployeeDocumentsAgg;
|
||||||
|
using Company.Domain.EmployeeFaceEmbeddingAgg;
|
||||||
using Company.Domain.empolyerAgg;
|
using Company.Domain.empolyerAgg;
|
||||||
using Company.Domain.Evidence;
|
using Company.Domain.Evidence;
|
||||||
using Company.Domain.EvidenceDetail;
|
using Company.Domain.EvidenceDetail;
|
||||||
@@ -23,38 +49,108 @@ using Company.Domain.FileEmployerAgg;
|
|||||||
using Company.Domain.FileState;
|
using Company.Domain.FileState;
|
||||||
using Company.Domain.FileTiming;
|
using Company.Domain.FileTiming;
|
||||||
using Company.Domain.FileTitle;
|
using Company.Domain.FileTitle;
|
||||||
|
using Company.Domain.FinancialInvoiceAgg;
|
||||||
|
using Company.Domain.FinancialStatmentAgg;
|
||||||
|
using Company.Domain.FinancialTransactionAgg;
|
||||||
|
using Company.Domain.FineAgg;
|
||||||
|
using Company.Domain.FineSubjectAgg;
|
||||||
|
using Company.Domain.GroupPlanAgg;
|
||||||
|
using Company.Domain.GroupPlanJobItemAgg;
|
||||||
using Company.Domain.HolidayAgg;
|
using Company.Domain.HolidayAgg;
|
||||||
using Company.Domain.HolidayItemAgg;
|
using Company.Domain.HolidayItemAgg;
|
||||||
|
using Company.Domain.InstitutionContractAgg;
|
||||||
|
using Company.Domain.InstitutionContractContactInfoAgg;
|
||||||
|
using Company.Domain.InstitutionContractExtensionTempAgg;
|
||||||
|
using Company.Domain.InstitutionPlanAgg;
|
||||||
|
using Company.Domain.InsuranceAgg;
|
||||||
|
using Company.Domain.InsuranceEmployeeInfoAgg;
|
||||||
|
using Company.Domain.InsuranceJobItemAgg;
|
||||||
|
using Company.Domain.InsuranceListAgg;
|
||||||
|
using Company.Domain.InsuranceYearlySalaryAgg;
|
||||||
|
using Company.Domain.InsurancJobAgg;
|
||||||
|
using Company.Domain.InsurancWorkshopInfoAgg;
|
||||||
using Company.Domain.JobAgg;
|
using Company.Domain.JobAgg;
|
||||||
|
using Company.Domain.LawAgg;
|
||||||
using Company.Domain.LeaveAgg;
|
using Company.Domain.LeaveAgg;
|
||||||
using Company.Domain.LeftWorkAgg;
|
using Company.Domain.LeftWorkAgg;
|
||||||
|
using Company.Domain.LeftWorkInsuranceAgg;
|
||||||
|
using Company.Domain.LeftWorkTempAgg;
|
||||||
|
using Company.Domain.LoanAgg;
|
||||||
using Company.Domain.MandatoryHoursAgg;
|
using Company.Domain.MandatoryHoursAgg;
|
||||||
using Company.Domain.MasterPenaltyTitle;
|
using Company.Domain.MasterPenaltyTitle;
|
||||||
using Company.Domain.MasterPetition;
|
using Company.Domain.MasterPetition;
|
||||||
using Company.Domain.MasterWorkHistory;
|
using Company.Domain.MasterWorkHistory;
|
||||||
using Company.Domain.ModuleAgg;
|
using Company.Domain.ModuleAgg;
|
||||||
using Company.Domain.OriginalTitleAgg;
|
using Company.Domain.OriginalTitleAgg;
|
||||||
|
using Company.Domain.PaymentInstrumentAgg;
|
||||||
|
using Company.Domain.PaymentToEmployeeAgg;
|
||||||
|
using Company.Domain.PaymentToEmployeeItemAgg;
|
||||||
|
using Company.Domain.PaymentTransactionAgg;
|
||||||
using Company.Domain.PenaltyTitle;
|
using Company.Domain.PenaltyTitle;
|
||||||
|
using Company.Domain.PercentageAgg;
|
||||||
|
using Company.Domain.PersonnelCodeAgg;
|
||||||
using Company.Domain.Petition;
|
using Company.Domain.Petition;
|
||||||
using Company.Domain.ProceedingSession;
|
using Company.Domain.ProceedingSession;
|
||||||
|
using Company.Domain.ReportAgg;
|
||||||
|
using Company.Domain.ReportClientAgg;
|
||||||
using Company.Domain.RepresentativeAgg;
|
using Company.Domain.RepresentativeAgg;
|
||||||
|
using Company.Domain.RewardAgg;
|
||||||
|
using Company.Domain.RollCallAgg;
|
||||||
|
using Company.Domain.RollCallAgg.DomainService;
|
||||||
|
using Company.Domain.RollCallEmployeeAgg;
|
||||||
|
using Company.Domain.RollCallEmployeeStatusAgg;
|
||||||
|
using Company.Domain.RollCallPlanAgg;
|
||||||
|
using Company.Domain.RollCallServiceAgg;
|
||||||
|
using Company.Domain.SalaryAidAgg;
|
||||||
|
using Company.Domain.SmsResultAgg;
|
||||||
using Company.Domain.SubtitleAgg;
|
using Company.Domain.SubtitleAgg;
|
||||||
|
using Company.Domain.TaxJobCategoryAgg;
|
||||||
|
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||||
using Company.Domain.WorkHistory;
|
using Company.Domain.WorkHistory;
|
||||||
using Company.Domain.WorkingHoursAgg;
|
using Company.Domain.WorkingHoursAgg;
|
||||||
using Company.Domain.WorkingHoursItemsAgg;
|
using Company.Domain.WorkingHoursItemsAgg;
|
||||||
|
using Company.Domain.WorkingHoursTempAgg;
|
||||||
|
using Company.Domain.WorkingHoursTempItemAgg;
|
||||||
|
using Company.Domain.WorkshopAccountAgg;
|
||||||
using Company.Domain.WorkshopAgg;
|
using Company.Domain.WorkshopAgg;
|
||||||
|
using Company.Domain.WorkshopPlanAgg;
|
||||||
|
using Company.Domain.WorkshopPlanEmployeeAgg;
|
||||||
|
using Company.Domain.WorkshopSubAccountAgg;
|
||||||
using Company.Domain.YearlySalaryAgg;
|
using Company.Domain.YearlySalaryAgg;
|
||||||
using Company.Domain.YearlySalaryItemsAgg;
|
using Company.Domain.YearlySalaryItemsAgg;
|
||||||
using Company.Domain.YearlysSalaryTitleAgg;
|
using Company.Domain.YearlysSalaryTitleAgg;
|
||||||
|
using Company.Domain.ZoneAgg;
|
||||||
|
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||||
|
using CompanyManagement.Infrastructure.Mongo.EmployeeFaceEmbeddingRepo;
|
||||||
|
using CompanyManagement.Infrastructure.Mongo.InstitutionContractInsertTempRepo;
|
||||||
|
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
|
||||||
|
using CompanyManagment.App.Contracts.AndroidApkVersion;
|
||||||
|
using CompanyManagment.App.Contracts.AuthorizedPerson;
|
||||||
|
using CompanyManagment.App.Contracts.Bank;
|
||||||
using CompanyManagment.App.Contracts.Board;
|
using CompanyManagment.App.Contracts.Board;
|
||||||
using CompanyManagment.App.Contracts.Chapter;
|
using CompanyManagment.App.Contracts.Chapter;
|
||||||
using CompanyManagment.App.Contracts.Checkout;
|
using CompanyManagment.App.Contracts.Checkout;
|
||||||
|
using CompanyManagment.App.Contracts.ClassifiedSalary;
|
||||||
using CompanyManagment.App.Contracts.Contact2;
|
using CompanyManagment.App.Contracts.Contact2;
|
||||||
|
using CompanyManagment.App.Contracts.ContactUs;
|
||||||
using CompanyManagment.App.Contracts.Contract;
|
using CompanyManagment.App.Contracts.Contract;
|
||||||
|
using CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
|
||||||
using CompanyManagment.App.Contracts.CrossJob;
|
using CompanyManagment.App.Contracts.CrossJob;
|
||||||
using CompanyManagment.App.Contracts.CrossJobGuild;
|
using CompanyManagment.App.Contracts.CrossJobGuild;
|
||||||
|
using CompanyManagment.App.Contracts.CrossJobItems;
|
||||||
|
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||||
|
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||||
|
using CompanyManagment.App.Contracts.DateSalary;
|
||||||
|
using CompanyManagment.App.Contracts.DateSalaryItem;
|
||||||
using CompanyManagment.App.Contracts.Employee;
|
using CompanyManagment.App.Contracts.Employee;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeBankInformation;
|
||||||
using CompanyManagment.App.Contracts.EmployeeChildren;
|
using CompanyManagment.App.Contracts.EmployeeChildren;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeComputeOptions;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeDocumentsAdminSelection;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
|
||||||
|
using CompanyManagment.App.Contracts.EmployeeInsurancListData;
|
||||||
using CompanyManagment.App.Contracts.Employer;
|
using CompanyManagment.App.Contracts.Employer;
|
||||||
using CompanyManagment.App.Contracts.Evidence;
|
using CompanyManagment.App.Contracts.Evidence;
|
||||||
using CompanyManagment.App.Contracts.EvidenceDetail;
|
using CompanyManagment.App.Contracts.EvidenceDetail;
|
||||||
@@ -65,33 +161,74 @@ using CompanyManagment.App.Contracts.FileEmployer;
|
|||||||
using CompanyManagment.App.Contracts.FileState;
|
using CompanyManagment.App.Contracts.FileState;
|
||||||
using CompanyManagment.App.Contracts.FileTiming;
|
using CompanyManagment.App.Contracts.FileTiming;
|
||||||
using CompanyManagment.App.Contracts.FileTitle;
|
using CompanyManagment.App.Contracts.FileTitle;
|
||||||
|
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||||
|
using CompanyManagment.App.Contracts.FinancialStatment;
|
||||||
|
using CompanyManagment.App.Contracts.FinancilTransaction;
|
||||||
|
using CompanyManagment.App.Contracts.Fine;
|
||||||
|
using CompanyManagment.App.Contracts.FineSubject;
|
||||||
using CompanyManagment.App.Contracts.Holiday;
|
using CompanyManagment.App.Contracts.Holiday;
|
||||||
using CompanyManagment.App.Contracts.HolidayItem;
|
using CompanyManagment.App.Contracts.HolidayItem;
|
||||||
|
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||||
|
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||||
|
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||||
|
using CompanyManagment.App.Contracts.Insurance;
|
||||||
|
using CompanyManagment.App.Contracts.InsuranceEmployeeInfo;
|
||||||
|
using CompanyManagment.App.Contracts.InsuranceJob;
|
||||||
|
using CompanyManagment.App.Contracts.InsuranceList;
|
||||||
|
using CompanyManagment.App.Contracts.InsuranceWorkshopInfo;
|
||||||
|
using CompanyManagment.App.Contracts.InsuranceYearlySalary;
|
||||||
using CompanyManagment.App.Contracts.Job;
|
using CompanyManagment.App.Contracts.Job;
|
||||||
|
using CompanyManagment.App.Contracts.Law;
|
||||||
using CompanyManagment.App.Contracts.Leave;
|
using CompanyManagment.App.Contracts.Leave;
|
||||||
using CompanyManagment.App.Contracts.LeftWork;
|
using CompanyManagment.App.Contracts.LeftWork;
|
||||||
|
using CompanyManagment.App.Contracts.LeftWorkInsurance;
|
||||||
|
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||||
|
using CompanyManagment.App.Contracts.Loan;
|
||||||
using CompanyManagment.App.Contracts.MandantoryHours;
|
using CompanyManagment.App.Contracts.MandantoryHours;
|
||||||
using CompanyManagment.App.Contracts.MasterPenaltyTitle;
|
using CompanyManagment.App.Contracts.MasterPenaltyTitle;
|
||||||
using CompanyManagment.App.Contracts.MasterPetition;
|
using CompanyManagment.App.Contracts.MasterPetition;
|
||||||
using CompanyManagment.App.Contracts.MasterWorkHistory;
|
using CompanyManagment.App.Contracts.MasterWorkHistory;
|
||||||
using CompanyManagment.App.Contracts.Module;
|
using CompanyManagment.App.Contracts.Module;
|
||||||
using CompanyManagment.App.Contracts.OriginalTitle;
|
using CompanyManagment.App.Contracts.OriginalTitle;
|
||||||
|
using CompanyManagment.App.Contracts.PaymentInstrument;
|
||||||
|
using CompanyManagment.App.Contracts.PaymentToEmployee;
|
||||||
|
using CompanyManagment.App.Contracts.PaymentTransaction;
|
||||||
using CompanyManagment.App.Contracts.PenaltyTitle;
|
using CompanyManagment.App.Contracts.PenaltyTitle;
|
||||||
|
using CompanyManagment.App.Contracts.Percentage;
|
||||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||||
|
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||||
using CompanyManagment.App.Contracts.Petition;
|
using CompanyManagment.App.Contracts.Petition;
|
||||||
using CompanyManagment.App.Contracts.ProceedingSession;
|
using CompanyManagment.App.Contracts.ProceedingSession;
|
||||||
|
using CompanyManagment.App.Contracts.Report;
|
||||||
|
using CompanyManagment.App.Contracts.ReportClient;
|
||||||
using CompanyManagment.App.Contracts.Representative;
|
using CompanyManagment.App.Contracts.Representative;
|
||||||
|
using CompanyManagment.App.Contracts.Reward;
|
||||||
|
using CompanyManagment.App.Contracts.RollCall;
|
||||||
|
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||||
|
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||||
|
using CompanyManagment.App.Contracts.RollCallPlan;
|
||||||
|
using CompanyManagment.App.Contracts.RollCallService;
|
||||||
|
using CompanyManagment.App.Contracts.SalaryAid;
|
||||||
|
using CompanyManagment.App.Contracts.SmsResult;
|
||||||
using CompanyManagment.App.Contracts.Subtitle;
|
using CompanyManagment.App.Contracts.Subtitle;
|
||||||
|
using CompanyManagment.App.Contracts.TaxJobCategory;
|
||||||
|
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||||
using CompanyManagment.App.Contracts.TextManager;
|
using CompanyManagment.App.Contracts.TextManager;
|
||||||
using CompanyManagment.App.Contracts.WorkHistory;
|
using CompanyManagment.App.Contracts.WorkHistory;
|
||||||
using CompanyManagment.App.Contracts.WorkingHours;
|
using CompanyManagment.App.Contracts.WorkingHours;
|
||||||
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
||||||
|
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||||
|
using CompanyManagment.App.Contracts.WorkingHoursTempItem;
|
||||||
using CompanyManagment.App.Contracts.Workshop;
|
using CompanyManagment.App.Contracts.Workshop;
|
||||||
|
using CompanyManagment.App.Contracts.WorkshopPlan;
|
||||||
using CompanyManagment.App.Contracts.YearlySalary;
|
using CompanyManagment.App.Contracts.YearlySalary;
|
||||||
using CompanyManagment.App.Contracts.YearlySalaryItems;
|
using CompanyManagment.App.Contracts.YearlySalaryItems;
|
||||||
using CompanyManagment.App.Contracts.YearlySalaryTitles;
|
using CompanyManagment.App.Contracts.YearlySalaryTitles;
|
||||||
|
using CompanyManagment.App.Contracts.Zone;
|
||||||
using CompanyManagment.Application;
|
using CompanyManagment.Application;
|
||||||
using CompanyManagment.EFCore;
|
using CompanyManagment.EFCore;
|
||||||
|
using CompanyManagment.EFCore._common;
|
||||||
|
using CompanyManagment.EFCore.Repository;
|
||||||
using CompanyManagment.EFCore.Repository;
|
using CompanyManagment.EFCore.Repository;
|
||||||
using File.EfCore.Repository;
|
using File.EfCore.Repository;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -237,6 +374,10 @@ using Company.Domain.CameraBugReportAgg;
|
|||||||
using CompanyManagment.App.Contracts.CameraBugReport;
|
using CompanyManagment.App.Contracts.CameraBugReport;
|
||||||
using CompanyManagement.Infrastructure.Mongo.CameraBugReportRepo;
|
using CompanyManagement.Infrastructure.Mongo.CameraBugReportRepo;
|
||||||
using CameraBugReportRepository = CompanyManagement.Infrastructure.Mongo.CameraBugReportRepo.CameraBugReportRepository;
|
using CameraBugReportRepository = CompanyManagement.Infrastructure.Mongo.CameraBugReportRepo.CameraBugReportRepository;
|
||||||
|
using Company.Domain._common;
|
||||||
|
using CompanyManagment.EFCore._common;
|
||||||
|
using CompanyManagment.EFCore.Services;
|
||||||
|
using Shared.Contracts.Holidays;
|
||||||
|
|
||||||
namespace PersonalContractingParty.Config;
|
namespace PersonalContractingParty.Config;
|
||||||
|
|
||||||
@@ -244,6 +385,12 @@ public class PersonalBootstrapper
|
|||||||
{
|
{
|
||||||
public static void Configure(IServiceCollection services, string connectionString)
|
public static void Configure(IServiceCollection services, string connectionString)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#region Services
|
||||||
|
|
||||||
|
services.AddTransient<IHolidayQueryService, HolidayQueryService>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
//----Task-Manager-Project---------------------------------
|
//----Task-Manager-Project---------------------------------
|
||||||
|
|
||||||
//services.AddTransient<ITaskApplication, TaskApplication>();
|
//services.AddTransient<ITaskApplication, TaskApplication>();
|
||||||
@@ -549,6 +696,13 @@ public class PersonalBootstrapper
|
|||||||
services.AddTransient<ISmsSettingsRepository, SmsSettingsRepository>();
|
services.AddTransient<ISmsSettingsRepository, SmsSettingsRepository>();
|
||||||
services.AddTransient<ISmsSettingApplication, SmsSettingApplication>();
|
services.AddTransient<ISmsSettingApplication, SmsSettingApplication>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region UnitOfWork
|
||||||
|
|
||||||
|
services.AddTransient<IUnitOfWork, UnitOfWork>();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
//=========End Of Main====================================
|
//=========End Of Main====================================
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using MediatR;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using GozareshgirProgramManager.Domain.CustomerAgg.Events;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.DomainEventHandlers;
|
||||||
|
|
||||||
|
public class CustomerRegisteredHandler : INotificationHandler<DomainEventNotification<CustomerRegistered>>
|
||||||
|
{
|
||||||
|
private readonly ILogger<CustomerRegisteredHandler> _logger;
|
||||||
|
|
||||||
|
public CustomerRegisteredHandler(ILogger<CustomerRegisteredHandler> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(DomainEventNotification<CustomerRegistered> notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var domainEvent = notification.DomainEvent;
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"Customer registered: {CustomerId}, Name: {Name}, Email: {Email}",
|
||||||
|
domainEvent.CustomerId,
|
||||||
|
domainEvent.Name,
|
||||||
|
domainEvent.Email);
|
||||||
|
|
||||||
|
|
||||||
|
// اینجا میتوانید email ارسال کنید یا کارهای دیگر انجام دهید
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.DomainEventHandlers.TaskSection;
|
||||||
|
|
||||||
|
public class ProjectSectionAddedHandler:INotificationHandler<DomainEventNotification<TaskSectionAddedEvent>>
|
||||||
|
{
|
||||||
|
private readonly ILogger<CustomerRegisteredHandler> _logger;
|
||||||
|
private readonly IBoardNotificationPublisher _boardNotificationPublisher;
|
||||||
|
|
||||||
|
public ProjectSectionAddedHandler(ILogger<CustomerRegisteredHandler> logger, IBoardNotificationPublisher boardNotificationPublisher)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_boardNotificationPublisher = boardNotificationPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(DomainEventNotification<TaskSectionAddedEvent> notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var domainEvent = notification.DomainEvent;
|
||||||
|
//_boardNotificationPublisher.NotifyTaskCreated()
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.DomainEventHandlers.TaskSection;
|
||||||
|
|
||||||
|
public class ProjectSectionAssignedHandler:INotificationHandler<DomainEventNotification<ProjectSectionAssignedEvent>>
|
||||||
|
{
|
||||||
|
public Task Handle(DomainEventNotification<ProjectSectionAssignedEvent> notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var domainEvent = notification.DomainEvent;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.DomainEventHandlers.TaskSection;
|
||||||
|
|
||||||
|
public class TaskSectionStatusChangedHandler:INotificationHandler<DomainEventNotification<TaskSectionStatusChangedEvent>>
|
||||||
|
{
|
||||||
|
private readonly IBoardNotificationPublisher _boardNotificationPublisher;
|
||||||
|
|
||||||
|
public TaskSectionStatusChangedHandler(IBoardNotificationPublisher boardNotificationPublisher)
|
||||||
|
{
|
||||||
|
_boardNotificationPublisher = boardNotificationPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(DomainEventNotification<TaskSectionStatusChangedEvent> notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var domainEvent = notification.DomainEvent;
|
||||||
|
_boardNotificationPublisher.NotifyTaskStatusChanged(domainEvent.UserId,domainEvent.OldStatus,domainEvent.NewStatus,domainEvent.SectionId);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FluentValidation" Version="12.1.1" />
|
||||||
|
<PackageReference Include="MediatR" Version="14.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\Shared.Contracts\Shared.Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Domain\GozareshgirProgramManager.Domain\GozareshgirProgramManager.Domain.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Interfaces;
|
||||||
|
|
||||||
|
public interface IBoardNotificationPublisher
|
||||||
|
{
|
||||||
|
Task NotifyTaskStatusChanged(long userId, TaskSectionStatus oldStatus,
|
||||||
|
TaskSectionStatus newStatus, Guid sectionId);
|
||||||
|
|
||||||
|
Task NotifyTaskCreated(TaskSection taskSection);
|
||||||
|
|
||||||
|
Task NotifyTaskAssigned(long userId, Guid sectionId);
|
||||||
|
|
||||||
|
Task NotifyTaskRemoved(long userId, Guid sectionId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
|
||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.CheckoutAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.CheckoutAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.CheckoutAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.DTOs;
|
||||||
|
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
||||||
|
using MediatR;
|
||||||
|
using PersianTools.Core;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Shared.Contracts.Holidays;
|
||||||
|
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Commands.CreateCheckout;
|
||||||
|
|
||||||
|
public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEditCheckoutCommand>
|
||||||
|
{
|
||||||
|
private readonly ICheckoutRepository _checkoutRepository;
|
||||||
|
private readonly ISalaryPaymentSettingRepository _salaryPaymentSettingRepository;
|
||||||
|
private readonly ITaskSectionActivityRepository _taskSectionActivityRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly IHolidayQueryService _holidayQueryService;
|
||||||
|
|
||||||
|
|
||||||
|
public CreateOrEditCheckoutCommandHandler(ICheckoutRepository checkoutRepository, IUnitOfWork unitOfWork,
|
||||||
|
ISalaryPaymentSettingRepository salaryPaymentSettingRepository,
|
||||||
|
ITaskSectionActivityRepository taskSectionActivityRepository, IHolidayQueryService holidayQueryService)
|
||||||
|
{
|
||||||
|
_checkoutRepository = checkoutRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_salaryPaymentSettingRepository = salaryPaymentSettingRepository;
|
||||||
|
_taskSectionActivityRepository = taskSectionActivityRepository;
|
||||||
|
_holidayQueryService = holidayQueryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(CreateOrEditCheckoutCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (request.TypeOfCheckoutHandler)
|
||||||
|
{
|
||||||
|
case TypeOfCheckoutHandler.CreateInGroup:
|
||||||
|
return await Create(request.Year, request.Month, request.UserIdList);
|
||||||
|
break;
|
||||||
|
case TypeOfCheckoutHandler.SingleEdit:
|
||||||
|
case TypeOfCheckoutHandler.GroupEditing:
|
||||||
|
return await GroupOrSingleEditing(request.CheckoutIdList);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return OperationResult.Failure("نوع متد انتخاب نشده است");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد گروهی فیش حقوقی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Year"></param>
|
||||||
|
/// <param name="Month"></param>
|
||||||
|
/// <param name="UserIdList"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<OperationResult> Create(string? Year, string? Month, List<long>? UserIdList)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Month))
|
||||||
|
return OperationResult.Failure("ماه خالی است");
|
||||||
|
if (string.IsNullOrWhiteSpace(Year))
|
||||||
|
return OperationResult.Failure("سال خالی است");
|
||||||
|
if (UserIdList == null)
|
||||||
|
return OperationResult.Failure("هیچ موردی برای ایجاد انتخاب نشده اشت");
|
||||||
|
if (UserIdList.Count == 0)
|
||||||
|
return OperationResult.Failure("هیچ موردی برای ایجاد انتخاب نشده اشت");
|
||||||
|
|
||||||
|
var startDateGr = new DateTime();
|
||||||
|
var EndDateGr = new DateTime();
|
||||||
|
var persianStart = new PersianDateTime();
|
||||||
|
|
||||||
|
int year = 0;
|
||||||
|
int month = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
year = Convert.ToInt32(Year);
|
||||||
|
month = Convert.ToInt32(Month);
|
||||||
|
persianStart = new PersianDateTime(year, month, 1);
|
||||||
|
var startDateFa = $"{persianStart}";
|
||||||
|
startDateGr = startDateFa.ToGeorgianDateTime();
|
||||||
|
|
||||||
|
var endDateFa = startDateFa.FindeEndOfMonth();
|
||||||
|
|
||||||
|
EndDateGr = endDateFa.ToGeorgianDateTime();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
return OperationResult<GetUserToGroupCreatingResponse>.Failure(
|
||||||
|
"خطا در ورود سال و ماه");
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalDays = Convert.ToInt32((EndDateGr - startDateGr).TotalDays + 1);
|
||||||
|
|
||||||
|
var getAllSettings = await _salaryPaymentSettingRepository.GetAllSettings(UserIdList);
|
||||||
|
var get = await _taskSectionActivityRepository.GetTotalTimeSpentPerUserInRangeAsync(startDateGr, EndDateGr);
|
||||||
|
|
||||||
|
foreach (var user in getAllSettings)
|
||||||
|
{
|
||||||
|
var totalWorked = get.FirstOrDefault(x => x.UserId == user.UserId);
|
||||||
|
var totalTimeTotalMinutes = (int)totalWorked.TotalTime.TotalMinutes;
|
||||||
|
var res = await ComputeSalary(user.WorkingHoursListDto, totalTimeTotalMinutes, user.MonthlySalary, startDateGr, EndDateGr, user.HolidayWorking);
|
||||||
|
var createCheckout = new Checkout(startDateGr, EndDateGr, year, month, user.FullName, user.UserId,
|
||||||
|
res.MandatoryHours, totalTimeTotalMinutes,
|
||||||
|
totalDays, res.RemainingHours, user.MonthlySalary, res.MonthlySalaryPay, res.DeductionFromSalary);
|
||||||
|
await _checkoutRepository.CreateAsync(createCheckout);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync();
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// متد ویراش گروهی و تکی
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="CheckoutIdList"></param>
|
||||||
|
/// <param name="CheckoutId"></param>
|
||||||
|
/// <param name="TypeOfCheckoutHandler"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<OperationResult> GroupOrSingleEditing(List<Guid>? CheckoutIdList)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (CheckoutIdList == null)
|
||||||
|
return OperationResult.Failure("هیچ موردی برای ویرایش انتخاب نشده اشت");
|
||||||
|
if (CheckoutIdList.Count == 0)
|
||||||
|
return OperationResult.Failure("هیچ موردی برای ویرایش انتخاب نشده اشت");
|
||||||
|
|
||||||
|
var checkouts = await _checkoutRepository.GetCheckoutListByIds(CheckoutIdList);
|
||||||
|
if (!checkouts.Any())
|
||||||
|
return OperationResult.Failure("هیچ موردی برای ویرایش انتخاب نشده اشت");
|
||||||
|
var UserIdList = checkouts.Select(x => x.UserId).ToList();
|
||||||
|
var getAllSettings = await _salaryPaymentSettingRepository.GetAllSettings(UserIdList);
|
||||||
|
if (!getAllSettings.Any())
|
||||||
|
return OperationResult.Failure("تنظیمات ساعت و حقوق یافت نشد");
|
||||||
|
foreach (var checkoutId in CheckoutIdList)
|
||||||
|
{
|
||||||
|
var checkout = checkouts.FirstOrDefault(x => x.Id == checkoutId);
|
||||||
|
if (checkout == null)
|
||||||
|
return OperationResult.Failure("فیش مورد نظر یافت نشد");
|
||||||
|
|
||||||
|
var userSetting = getAllSettings.FirstOrDefault(x => x.UserId == checkout.UserId);
|
||||||
|
|
||||||
|
var get = await _taskSectionActivityRepository.GetTotalTimeSpentByUserInRangeAsync(checkout.UserId, checkout.CheckoutStartDate, checkout.CheckoutEndDate);
|
||||||
|
|
||||||
|
var totalTimeTotalMinutes = (int)get.TotalMinutes;
|
||||||
|
|
||||||
|
var totalDays = Convert.ToInt32((checkout.CheckoutEndDate - checkout.CheckoutStartDate).TotalDays + 1);
|
||||||
|
var res = await ComputeSalary(userSetting.WorkingHoursListDto, totalTimeTotalMinutes, userSetting.MonthlySalary, checkout.CheckoutStartDate, checkout.CheckoutEndDate, userSetting.HolidayWorking);
|
||||||
|
checkout.Edit(res.MandatoryHours, totalTimeTotalMinutes, totalDays, res.RemainingHours, userSetting.MonthlySalary, res.MonthlySalaryPay, res.DeductionFromSalary);
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محاسبه حقوق
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ComputeResultDto> ComputeSalary(List<WorkingHoursListDto> workingHoursListDto, int totalHoursWorked, double monthlySalaryDefined, DateTime start, DateTime end, bool holidayWorking)
|
||||||
|
{
|
||||||
|
var startDate = start.ToFarsi();
|
||||||
|
var startYear = Convert.ToInt32(startDate.Substring(0, 4));
|
||||||
|
var startMonth = Convert.ToInt32(startDate.Substring(5, 2));
|
||||||
|
var startDay = Convert.ToInt32(startDate.Substring(8, 2));
|
||||||
|
var persianStart = new PersianDateTime(startYear, startMonth, startDay);
|
||||||
|
var endDate = end.ToFarsi();
|
||||||
|
var endYear = Convert.ToInt32(endDate.Substring(0, 4));
|
||||||
|
var endMonth = Convert.ToInt32(endDate.Substring(5, 2));
|
||||||
|
var endDay = Convert.ToInt32(endDate.Substring(8, 2));
|
||||||
|
var persianEnd = new PersianDateTime(endYear, endMonth, endDay);
|
||||||
|
var holidays = await _holidayQueryService.GetHolidaysInDates(start, end);
|
||||||
|
int mandatoryHours = 0;
|
||||||
|
for (var currentDay = persianStart; currentDay <= persianEnd; currentDay = currentDay.AddDays(1))
|
||||||
|
{
|
||||||
|
var currentDayOfWeek = new DNTPersianUtils.Core.PersianDateTime(currentDay.Year, currentDay.Month, currentDay.Day);
|
||||||
|
var holidayDate = currentDay.ShamsiDate.ToGeorgianDateTime();
|
||||||
|
var day = (PersianDayOfWeek)currentDayOfWeek.WeekDayNumber!;
|
||||||
|
var getDaySetting = workingHoursListDto.FirstOrDefault(x => x.PersianDayOfWeek == day);
|
||||||
|
if (getDaySetting != null)
|
||||||
|
{
|
||||||
|
if (!holidayWorking && holidays.Any(x => x.Holidaydate == holidayDate))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mandatoryHours += (int)getDaySetting.ShiftDuration.TotalMinutes;
|
||||||
|
Console.WriteLine((int)getDaySetting.ShiftDuration.TotalMinutes + " " + currentDay + " - " + day);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//حقوق نهایی
|
||||||
|
var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
|
||||||
|
// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
|
||||||
|
monthlySalaryPay = monthlySalaryPay > monthlySalaryDefined ? monthlySalaryDefined : monthlySalaryPay;
|
||||||
|
|
||||||
|
//حقوق کسر شده
|
||||||
|
var deductionFromSalary = monthlySalaryDefined - monthlySalaryPay;
|
||||||
|
|
||||||
|
//زمان باقی مانده
|
||||||
|
var remainingTime = totalHoursWorked - mandatoryHours;
|
||||||
|
|
||||||
|
var computeResult = new ComputeResultDto
|
||||||
|
{
|
||||||
|
MandatoryHours = mandatoryHours,
|
||||||
|
MonthlySalaryPay = monthlySalaryPay,
|
||||||
|
DeductionFromSalary = deductionFromSalary,
|
||||||
|
RemainingHours = remainingTime
|
||||||
|
};
|
||||||
|
Console.WriteLine(mandatoryHours);
|
||||||
|
return computeResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public record CreateOrEditCheckoutCommand(TypeOfCheckoutHandler TypeOfCheckoutHandler, string? Year, string? Month, List<long>? UserIdList, List<Guid>? CheckoutIdList) : IBaseCommand;
|
||||||
|
|
||||||
|
public record ComputeResultDto
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ساعات باقی مانده
|
||||||
|
/// کسر کار یا اضافه کار
|
||||||
|
/// </summary>
|
||||||
|
public int RemainingHours { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حقوق نهایی که به پرسنل داده می شود
|
||||||
|
/// </summary>
|
||||||
|
public double MonthlySalaryPay { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کسر از حقوق
|
||||||
|
/// </summary>
|
||||||
|
public double DeductionFromSalary { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ساعت موظفی
|
||||||
|
/// </summary>
|
||||||
|
public int MandatoryHours { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Extensions;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetCheckoutList;
|
||||||
|
|
||||||
|
public class GetCheckoutListQueryHandler : IBasePaginationQueryHandler<GetCheckoutListQuery, GetCheckoutListResponse>
|
||||||
|
{
|
||||||
|
private readonly IProgramManagerDbContext _programManagerDbContext;
|
||||||
|
|
||||||
|
public GetCheckoutListQueryHandler(IProgramManagerDbContext programManagerDbContext)
|
||||||
|
{
|
||||||
|
_programManagerDbContext = programManagerDbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<PaginationResult<GetCheckoutListResponse>>> Handle(GetCheckoutListQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _programManagerDbContext.Checkouts.AsQueryable();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Year))
|
||||||
|
{
|
||||||
|
var year = Convert.ToInt32(request.Year);
|
||||||
|
query = query.Where(x => x.Year == year);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Month))
|
||||||
|
{
|
||||||
|
var month = Convert.ToInt32(request.Month);
|
||||||
|
query = query.Where(x => x.Month == month);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.FullName))
|
||||||
|
query = query.Where(x => x.FullName.Contains(request.FullName));
|
||||||
|
|
||||||
|
var res =await query.Select(x => new GetCheckoutListResponse()
|
||||||
|
{
|
||||||
|
CheckoutId = x.Id,
|
||||||
|
Year = x.Year,
|
||||||
|
Month = x.PersianMonthName,
|
||||||
|
FullName = x.FullName,
|
||||||
|
MandatoryHours = x.MandatoryHours,
|
||||||
|
TotalHoursWorked = x.TotalHoursWorked,
|
||||||
|
RemainingHours = x.RemainingHours,
|
||||||
|
MonthlySalaryDefined = x.MonthlySalaryDefined.ToMoney(),
|
||||||
|
DeductionFromSalary = x.DeductionFromSalary.ToMoney(),
|
||||||
|
MonthlySalaryPay = x.MonthlySalaryPay.ToMoney()
|
||||||
|
|
||||||
|
|
||||||
|
}).ApplyPagination(request.PageIndex,request.PageSize).ToListAsync(cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
var response = new PaginationResult<GetCheckoutListResponse>
|
||||||
|
{
|
||||||
|
List = res,
|
||||||
|
TotalCount = query.Count(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return OperationResult<PaginationResult<GetCheckoutListResponse>>.Success(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record GetCheckoutListQuery(string? Month, string? Year, string? FullName) : PaginationRequest, IBasePaginationQuery<GetCheckoutListResponse>;
|
||||||
|
|
||||||
|
public record GetCheckoutListResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی فیش حقوقی
|
||||||
|
/// </summary>
|
||||||
|
public Guid CheckoutId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// سال
|
||||||
|
/// </summary>
|
||||||
|
public int Year { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ماه
|
||||||
|
/// </summary>
|
||||||
|
public string Month { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ساعت موظفی
|
||||||
|
/// </summary>
|
||||||
|
public int MandatoryHours { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مجموع ساعات کارکرد پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public int TotalHoursWorked { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ساعات باقی مانده
|
||||||
|
/// کسر کار یا اضافه کار
|
||||||
|
/// </summary>
|
||||||
|
public int RemainingHours { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حقوق ماهانه
|
||||||
|
/// تعیین شده
|
||||||
|
/// </summary>
|
||||||
|
public string MonthlySalaryDefined { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کسر از حقوق
|
||||||
|
/// </summary>
|
||||||
|
public string DeductionFromSalary { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حقوق نهایی که به پرسنل داده می شود
|
||||||
|
/// </summary>
|
||||||
|
public string MonthlySalaryPay { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetUserListWhoHaveSettings;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.CheckoutAgg.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PersianTools.Core;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت کاربران برای ایجاد گروهی فیش حقوقی با سال و ماه
|
||||||
|
/// </summary>
|
||||||
|
public class GetUserToGroupCreatingQueryHandler : IBaseQueryHandler<GetUserToGroupCreatingQuery, GetUserToGroupCreatingResponse>
|
||||||
|
{
|
||||||
|
private readonly IProgramManagerDbContext _context;
|
||||||
|
|
||||||
|
public GetUserToGroupCreatingQueryHandler(IProgramManagerDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<GetUserToGroupCreatingResponse>> Handle(GetUserToGroupCreatingQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
//سال و ماه انتخاب شده از فرانت
|
||||||
|
var selectedDate = new DateTime();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int year = Convert.ToInt32(request.Year);
|
||||||
|
int month = Convert.ToInt32(request.Month);
|
||||||
|
selectedDate = ($"{new PersianDateTime(year,month,1)}").ToGeorgianDateTime();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
return OperationResult<GetUserToGroupCreatingResponse>.Failure(
|
||||||
|
"خطا در ورود سال و ماه");
|
||||||
|
}
|
||||||
|
|
||||||
|
//آخرین تاریخ مجاز برای ایجاد فیش
|
||||||
|
var lastMonth = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
|
||||||
|
|
||||||
|
if (selectedDate > lastMonth)
|
||||||
|
return OperationResult<GetUserToGroupCreatingResponse>.Failure(
|
||||||
|
"ایجاد فیش فقط برای ماه های گذشته امکان پذیر است");
|
||||||
|
|
||||||
|
|
||||||
|
var lastMonthStart = lastMonth;
|
||||||
|
var lastMonthEnd = lastMonth;
|
||||||
|
|
||||||
|
var query =
|
||||||
|
await (from u in _context.Users
|
||||||
|
|
||||||
|
// LEFT JOIN
|
||||||
|
// تنظیمات حقوق
|
||||||
|
join s in _context.SalaryPaymentSettings
|
||||||
|
on u.Id equals s.UserId into sJoin
|
||||||
|
from s in sJoin.DefaultIfEmpty()
|
||||||
|
|
||||||
|
// LEFT JOIN
|
||||||
|
//فیش
|
||||||
|
join ch in _context.Checkouts
|
||||||
|
.Where(x => x.CheckoutStartDate < lastMonthStart
|
||||||
|
&& x.CheckoutEndDate >= lastMonthStart)
|
||||||
|
on u.Id equals ch.UserId into chJoin
|
||||||
|
from ch in chJoin.DefaultIfEmpty()
|
||||||
|
|
||||||
|
group new { s, ch } by new { u.Id, u.FullName } into g
|
||||||
|
|
||||||
|
select new GetUserWhoHaveSettingsAndCheckoutDto
|
||||||
|
{
|
||||||
|
UserId = g.Key.Id,
|
||||||
|
FullName = g.Key.FullName,
|
||||||
|
|
||||||
|
HasSalarySettings = g.Any(x => x.s != null),
|
||||||
|
HasCheckout = g.Any(x => x.ch != null)
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var responseList = query.Select(x =>
|
||||||
|
{
|
||||||
|
|
||||||
|
bool validToCreate = x.HasSalarySettings && !x.HasCheckout;
|
||||||
|
string message = "آماده تنظیم";
|
||||||
|
CreateCheckoutStatus createCheckoutStatus = CreateCheckoutStatus.ReadyToCreate;
|
||||||
|
if (x.HasCheckout)
|
||||||
|
{
|
||||||
|
message = "موجود است";
|
||||||
|
createCheckoutStatus = CreateCheckoutStatus.AlreadyCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!x.HasSalarySettings)
|
||||||
|
{
|
||||||
|
message = "فاقد تنظیمات";
|
||||||
|
createCheckoutStatus = CreateCheckoutStatus.NotSetSalaryPaymentSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return new GetUserToGroupCreatingDto
|
||||||
|
{
|
||||||
|
UserId = x.UserId,
|
||||||
|
FullName = x.FullName,
|
||||||
|
IsValidToCreate = validToCreate,
|
||||||
|
StatusMessage = message,
|
||||||
|
CreateCheckoutStatus = createCheckoutStatus
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}).OrderByDescending(x=>x.IsValidToCreate).ToList();
|
||||||
|
|
||||||
|
var response = new GetUserToGroupCreatingResponse(responseList);
|
||||||
|
|
||||||
|
return OperationResult<GetUserToGroupCreatingResponse>.Success(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public record GetUserToGroupCreatingQuery(string Year, string Month) : IBaseQuery<GetUserToGroupCreatingResponse>;
|
||||||
|
|
||||||
|
public record GetUserToGroupCreatingResponse(List<GetUserToGroupCreatingDto> GetUserToGroupCreatingDtoList);
|
||||||
|
|
||||||
|
public record GetUserToGroupCreatingDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی کاربر
|
||||||
|
/// </summary>
|
||||||
|
public long UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پیام وضعیت ایجاد فیش
|
||||||
|
/// </summary>
|
||||||
|
public string StatusMessage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا مجاز به ایجاد فیش می باشد
|
||||||
|
/// </summary>
|
||||||
|
public bool IsValidToCreate { get; set; }
|
||||||
|
|
||||||
|
public CreateCheckoutStatus CreateCheckoutStatus { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public record GetUserWhoHaveSettingsAndCheckoutDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی کاربر
|
||||||
|
/// </summary>
|
||||||
|
public long UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// داشتن تنظیمات
|
||||||
|
/// </summary>
|
||||||
|
public bool HasSalarySettings { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool HasCheckout { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddPhaseToProject;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command to add a phase to an existing project
|
||||||
|
/// </summary>
|
||||||
|
public record AddPhaseToProjectCommand(
|
||||||
|
Guid ProjectId,
|
||||||
|
string Name,
|
||||||
|
string? Description = null,
|
||||||
|
int OrderIndex = 0
|
||||||
|
) : IBaseCommand;
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddPhaseToProject;
|
||||||
|
|
||||||
|
public class AddPhaseToProjectCommandHandler : IRequestHandler<AddPhaseToProjectCommand, OperationResult>
|
||||||
|
{
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public AddPhaseToProjectCommandHandler(
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IUnitOfWork unitOfWork)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(AddPhaseToProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get project
|
||||||
|
var project = await _projectRepository.GetByIdAsync(request.ProjectId);
|
||||||
|
if (project == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add phase
|
||||||
|
var phase = project.AddPhase(request.Name, request.Description);
|
||||||
|
phase.SetOrderIndex(request.OrderIndex);
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return OperationResult.Failure($"خطا در افزودن فاز: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command to add a task to an existing phase
|
||||||
|
/// </summary>
|
||||||
|
public record AddTaskToPhaseCommand(
|
||||||
|
Guid PhaseId,
|
||||||
|
string Name,
|
||||||
|
string? Description = null,
|
||||||
|
TaskPriority Priority = TaskPriority.Medium,
|
||||||
|
int OrderIndex = 0,
|
||||||
|
DateTime? DueDate = null
|
||||||
|
) : IBaseCommand;
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
||||||
|
|
||||||
|
public class AddTaskToPhaseCommandHandler : IRequestHandler<AddTaskToPhaseCommand, OperationResult>
|
||||||
|
{
|
||||||
|
private readonly IProjectPhaseRepository _phaseRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public AddTaskToPhaseCommandHandler(
|
||||||
|
IProjectPhaseRepository phaseRepository,
|
||||||
|
IUnitOfWork unitOfWork)
|
||||||
|
{
|
||||||
|
_phaseRepository = phaseRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(AddTaskToPhaseCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get phase
|
||||||
|
var phase = await _phaseRepository.GetByIdAsync(request.PhaseId);
|
||||||
|
if (phase == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("فاز یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add task
|
||||||
|
var task = phase.AddTask(request.Name, request.Description);
|
||||||
|
task.SetPriority(request.Priority);
|
||||||
|
task.SetOrderIndex(request.OrderIndex);
|
||||||
|
|
||||||
|
if (request.DueDate.HasValue)
|
||||||
|
{
|
||||||
|
task.SetDates(dueDate: request.DueDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return OperationResult.Failure($"خطا در افزودن تسک: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject;
|
||||||
|
|
||||||
|
public class AssignProjectCommand:IBaseCommand
|
||||||
|
{
|
||||||
|
public List<AssignProjectCommandItem> Items { get; set; }
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public ProjectHierarchyLevel Level { get; set; }
|
||||||
|
public bool CascadeToChildren { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssignProjectCommandItem
|
||||||
|
{
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public Guid SkillId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,274 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject;
|
||||||
|
|
||||||
|
public class AssignProjectCommandHandler:IBaseCommandHandler<AssignProjectCommand>
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||||
|
private readonly IProjectTaskRepository _projectTaskRepository;
|
||||||
|
private readonly ISkillRepository _skillRepository;
|
||||||
|
private readonly IPhaseSectionRepository _phaseSectionRepository;
|
||||||
|
private readonly IProjectSectionRepository _projectSectionRepository;
|
||||||
|
private readonly ITaskSectionRepository _taskSectionRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public AssignProjectCommandHandler(
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IProjectPhaseRepository projectPhaseRepository,
|
||||||
|
IProjectTaskRepository projectTaskRepository,
|
||||||
|
IUnitOfWork unitOfWork,
|
||||||
|
ISkillRepository skillRepository,
|
||||||
|
IPhaseSectionRepository phaseSectionRepository,
|
||||||
|
IProjectSectionRepository projectSectionRepository,
|
||||||
|
ITaskSectionRepository taskSectionRepository)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_projectPhaseRepository = projectPhaseRepository;
|
||||||
|
_projectTaskRepository = projectTaskRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_skillRepository = skillRepository;
|
||||||
|
_phaseSectionRepository = phaseSectionRepository;
|
||||||
|
_projectSectionRepository = projectSectionRepository;
|
||||||
|
_taskSectionRepository = taskSectionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(AssignProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
return await AssignProject(request);
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
return await AssignProjectPhase(request);
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
return await AssignProjectTask(request);
|
||||||
|
default:
|
||||||
|
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> AssignProject(AssignProjectCommand request)
|
||||||
|
{
|
||||||
|
var project = await _projectRepository.GetWithFullHierarchyAsync(request.Id);
|
||||||
|
if (project is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// تخصیص در سطح پروژه
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var skill = await _skillRepository.GetByIdAsync(item.SkillId);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound($"مهارت با شناسه {item.SkillId} یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// بررسی و بهروزرسانی یا اضافه کردن ProjectSection
|
||||||
|
var existingSection = project.ProjectSections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (existingSection != null)
|
||||||
|
{
|
||||||
|
// اگر وجود داشت، فقط userId را بهروزرسانی کن
|
||||||
|
existingSection.UpdateUser(item.UserId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// اگر وجود نداشت، اضافه کن
|
||||||
|
var newSection = new ProjectSection(project.Id, item.UserId, item.SkillId);
|
||||||
|
await _projectSectionRepository.CreateAsync(newSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// حالا برای تمام فازها و تسکها cascade کن
|
||||||
|
foreach (var phase in project.Phases)
|
||||||
|
{
|
||||||
|
// اگر CascadeToChildren true است یا فاز override ندارد
|
||||||
|
if (request.CascadeToChildren || !phase.HasAssignmentOverride)
|
||||||
|
{
|
||||||
|
// برای phase هم باید sectionها را بهروزرسانی کنیم
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var existingSection = phase.PhaseSections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (existingSection != null)
|
||||||
|
{
|
||||||
|
existingSection.Update(item.UserId, item.SkillId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newPhaseSection = new PhaseSection(phase.Id, item.UserId, item.SkillId);
|
||||||
|
await _phaseSectionRepository.CreateAsync(newPhaseSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var task in phase.Tasks)
|
||||||
|
{
|
||||||
|
// اگر CascadeToChildren true است یا تسک override ندارد
|
||||||
|
if (request.CascadeToChildren || !task.HasAssignmentOverride)
|
||||||
|
{
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var section = task.Sections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (section != null)
|
||||||
|
{
|
||||||
|
// استفاده از TransferToUser
|
||||||
|
if (section.CurrentAssignedUserId != item.UserId)
|
||||||
|
{
|
||||||
|
if (section.CurrentAssignedUserId > 0)
|
||||||
|
{
|
||||||
|
section.TransferToUser(section.CurrentAssignedUserId, item.UserId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
section.AssignToUser(item.UserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newTaskSection = new TaskSection(task.Id, item.SkillId, item.UserId);
|
||||||
|
await _taskSectionRepository.CreateAsync(newTaskSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync();
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> AssignProjectPhase(AssignProjectCommand request)
|
||||||
|
{
|
||||||
|
var phase = await _projectPhaseRepository.GetWithTasksAsync(request.Id);
|
||||||
|
if (phase is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("فاز پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// تخصیص در سطح فاز
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var skill = await _skillRepository.GetByIdAsync(item.SkillId);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound($"مهارت با شناسه {item.SkillId} یافت نشد");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// علامتگذاری که این فاز نسبت به parent متمایز است
|
||||||
|
phase.MarkAsOverridden();
|
||||||
|
|
||||||
|
// بهروزرسانی یا اضافه کردن PhaseSection
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var existingSection = phase.PhaseSections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (existingSection != null)
|
||||||
|
{
|
||||||
|
// اگر وجود داشت، فقط userId را بهروزرسانی کن
|
||||||
|
existingSection.Update(item.UserId, item.SkillId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// اگر وجود نداشت، اضافه کن
|
||||||
|
var newPhaseSection = new PhaseSection(phase.Id, item.UserId, item.SkillId);
|
||||||
|
await _phaseSectionRepository.CreateAsync(newPhaseSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cascade به تمام تسکها
|
||||||
|
foreach (var task in phase.Tasks)
|
||||||
|
{
|
||||||
|
// اگر CascadeToChildren true است یا تسک override ندارد
|
||||||
|
if (request.CascadeToChildren || !task.HasAssignmentOverride)
|
||||||
|
{
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var section = task.Sections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (section != null)
|
||||||
|
{
|
||||||
|
// استفاده از TransferToUser
|
||||||
|
if (section.CurrentAssignedUserId != item.UserId)
|
||||||
|
{
|
||||||
|
if (section.CurrentAssignedUserId > 0)
|
||||||
|
{
|
||||||
|
section.TransferToUser(section.CurrentAssignedUserId, item.UserId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
section.AssignToUser(item.UserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newTaskSection = new TaskSection(task.Id, item.SkillId, item.UserId);
|
||||||
|
await _taskSectionRepository.CreateAsync(newTaskSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync();
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> AssignProjectTask(AssignProjectCommand request)
|
||||||
|
{
|
||||||
|
var task = await _projectTaskRepository.GetWithSectionsAsync(request.Id);
|
||||||
|
if (task is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("تسک یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var skill = await _skillRepository.GetByIdAsync(item.SkillId);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound($"مهارت با شناسه {item.SkillId} یافت نشد");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// علامتگذاری که این تسک نسبت به parent متمایز است
|
||||||
|
task.MarkAsOverridden();
|
||||||
|
|
||||||
|
// بهروزرسانی یا اضافه کردن TaskSection
|
||||||
|
foreach (var item in request.Items)
|
||||||
|
{
|
||||||
|
var section = task.Sections.FirstOrDefault(s => s.SkillId == item.SkillId);
|
||||||
|
if (section != null)
|
||||||
|
{
|
||||||
|
// اگر وجود داشت، از TransferToUser استفاده کن
|
||||||
|
if (section.CurrentAssignedUserId != item.UserId)
|
||||||
|
{
|
||||||
|
if (section.CurrentAssignedUserId > 0)
|
||||||
|
{
|
||||||
|
section.TransferToUser(section.CurrentAssignedUserId, item.UserId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
section.AssignToUser(item.UserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// اگر وجود نداشت، اضافه کن
|
||||||
|
var newTaskSection = new TaskSection(task.Id, item.SkillId, item.UserId);
|
||||||
|
await _taskSectionRepository.CreateAsync(newTaskSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync();
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject;
|
||||||
|
|
||||||
|
public class AssignProjectCommandValidator : AbstractValidator<AssignProjectCommand>
|
||||||
|
{
|
||||||
|
public AssignProjectCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Id)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه پروژه نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
RuleFor(x => x.CascadeToChildren)
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("مقدار CascadeToChildren نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
RuleForEach(x => x.Items)
|
||||||
|
.SetValidator(new AssignProjectItemValidator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssignProjectItemValidator : AbstractValidator<AssignProjectCommandItem>
|
||||||
|
{
|
||||||
|
public AssignProjectItemValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.UserId)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.GreaterThan(0)
|
||||||
|
.WithMessage("شناسه کاربر نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
|
||||||
|
RuleFor(x => x.SkillId)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه مهارت نمیتواند خالی باشد");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeStatusSection;
|
||||||
|
|
||||||
|
public record ChangeStatusSectionCommand(Guid SectionId, TaskSectionStatus Status) : IBaseCommand;
|
||||||
|
|
||||||
|
public class ChangeStatusSectionCommandHandler : IBaseCommandHandler<ChangeStatusSectionCommand>
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly ITaskSectionRepository _taskSectionRepository;
|
||||||
|
private readonly IAuthHelper _authHelper;
|
||||||
|
|
||||||
|
public ChangeStatusSectionCommandHandler(ITaskSectionRepository taskSectionRepository,
|
||||||
|
IUnitOfWork unitOfWork, IAuthHelper authHelper)
|
||||||
|
{
|
||||||
|
_taskSectionRepository = taskSectionRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_authHelper = authHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(ChangeStatusSectionCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// استفاده از متد مخصوص که Activities رو load میکنه
|
||||||
|
var section = await _taskSectionRepository.GetByIdWithActivitiesAsync(request.SectionId, cancellationToken);
|
||||||
|
if (section == null)
|
||||||
|
return OperationResult.NotFound("بخش مورد نظر یافت نشد");
|
||||||
|
|
||||||
|
if (section.Status == request.Status)
|
||||||
|
return OperationResult.Success();
|
||||||
|
|
||||||
|
long currentUser = _authHelper.GetCurrentUserId()
|
||||||
|
?? throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||||
|
|
||||||
|
// Validate state transitions
|
||||||
|
var validationResult = ValidateStateTransition(section.Status, request.Status);
|
||||||
|
if (!validationResult.IsSuccess)
|
||||||
|
return validationResult;
|
||||||
|
|
||||||
|
// Handle state machine logic
|
||||||
|
if (section.Status == TaskSectionStatus.InProgress)
|
||||||
|
{
|
||||||
|
// Coming FROM InProgress: Stop the active activity
|
||||||
|
section.StopWork(request.Status);
|
||||||
|
}
|
||||||
|
else if (request.Status == TaskSectionStatus.InProgress)
|
||||||
|
{
|
||||||
|
// Going TO InProgress: Start work and create activity
|
||||||
|
section.StartWork();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// All other transitions: Just update status
|
||||||
|
section.UpdateStatus(request.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates state transitions based on business rules:
|
||||||
|
/// - ReadyToStart: شروع نشده - Initial state only, cannot return to it once left
|
||||||
|
/// - InProgress: درحال انجام - Can transition from ReadyToStart, can go to Incomplete or Completed
|
||||||
|
/// - Incomplete: نیمه کاره - Can come from InProgress or other states
|
||||||
|
/// - Completed: اتمام رسیده - Can come from InProgress or other states
|
||||||
|
/// </summary>
|
||||||
|
private OperationResult ValidateStateTransition(TaskSectionStatus currentStatus, TaskSectionStatus targetStatus)
|
||||||
|
{
|
||||||
|
// Cannot transition to ReadyToStart once the section has been started
|
||||||
|
if (targetStatus == TaskSectionStatus.ReadyToStart)
|
||||||
|
return OperationResult.ValidationError("بخش نمیتواند به وضعیت 'آماده برای شروع' تغییر کند");
|
||||||
|
|
||||||
|
// From ReadyToStart, can only go to InProgress
|
||||||
|
if (currentStatus == TaskSectionStatus.ReadyToStart && targetStatus != TaskSectionStatus.InProgress)
|
||||||
|
return OperationResult.ValidationError("از وضعیت 'آماده برای شروع' فقط میتوان به 'درحال انجام' رفت");
|
||||||
|
|
||||||
|
// Valid transitions matrix
|
||||||
|
var validTransitions = new Dictionary<TaskSectionStatus, List<TaskSectionStatus>>
|
||||||
|
{
|
||||||
|
{ TaskSectionStatus.ReadyToStart, [TaskSectionStatus.InProgress] },
|
||||||
|
{ TaskSectionStatus.InProgress, [TaskSectionStatus.Incomplete, TaskSectionStatus.Completed] },
|
||||||
|
{ TaskSectionStatus.Incomplete, [TaskSectionStatus.InProgress, TaskSectionStatus.Completed] },
|
||||||
|
{ TaskSectionStatus.Completed, [TaskSectionStatus.InProgress, TaskSectionStatus.Incomplete] }, // Can return to InProgress or Incomplete
|
||||||
|
{ TaskSectionStatus.NotAssigned, [TaskSectionStatus.InProgress, TaskSectionStatus.ReadyToStart] }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!validTransitions.TryGetValue(currentStatus, out var allowedTargets))
|
||||||
|
return OperationResult.ValidationError($"وضعیت فعلی '{currentStatus}' نامعتبر است");
|
||||||
|
|
||||||
|
if (!allowedTargets.Contains(targetStatus))
|
||||||
|
return OperationResult.ValidationError(
|
||||||
|
$"نمیتوان از وضعیت '{currentStatus}' به '{targetStatus}' رفت");
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeStatusSection;
|
||||||
|
|
||||||
|
public class ChangeStatusSectionCommandValidator:AbstractValidator<ChangeStatusSectionCommand>
|
||||||
|
{
|
||||||
|
public ChangeStatusSectionCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(c => c.SectionId)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه بخش نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
RuleFor(c => c.Status)
|
||||||
|
.IsInEnum()
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("وضعیت بخش نامعتبر است");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||||
|
|
||||||
|
public record CreateProjectCommand(string Name,ProjectHierarchyLevel Level,
|
||||||
|
Guid? ParentId):IBaseCommand;
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||||
|
|
||||||
|
public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectCommand>
|
||||||
|
{
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||||
|
private readonly IProjectTaskRepository _projectTaskRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
|
||||||
|
public CreateProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork, IProjectTaskRepository projectTaskRepository, IProjectPhaseRepository projectPhaseRepository)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_projectTaskRepository = projectTaskRepository;
|
||||||
|
_projectPhaseRepository = projectPhaseRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(CreateProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
await CreateProject(request);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
await CreateProjectPhase(request);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
await CreateProjectTask(request);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateProject(CreateProjectCommand request)
|
||||||
|
{
|
||||||
|
var project = new Project(request.Name);
|
||||||
|
await _projectRepository.CreateAsync(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateProjectPhase(CreateProjectCommand request)
|
||||||
|
{
|
||||||
|
if (!request.ParentId.HasValue)
|
||||||
|
throw new BadRequestException("برای ایجاد فاز، شناسه پروژه الزامی است");
|
||||||
|
|
||||||
|
if(!_projectRepository.Exists(x=>x.Id == request.ParentId.Value))
|
||||||
|
{
|
||||||
|
throw new BadRequestException("والد پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectPhase = new ProjectPhase(request.Name, request.ParentId.Value);
|
||||||
|
await _projectPhaseRepository.CreateAsync(projectPhase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateProjectTask(CreateProjectCommand request)
|
||||||
|
{
|
||||||
|
if (!request.ParentId.HasValue)
|
||||||
|
throw new BadRequestException("برای ایجاد تسک، شناسه فاز الزامی است");
|
||||||
|
|
||||||
|
if(!_projectPhaseRepository.Exists(x=>x.Id == request.ParentId.Value))
|
||||||
|
{
|
||||||
|
throw new BadRequestException("والد پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectTask = new ProjectTask(request.Name, request.ParentId.Value);
|
||||||
|
await _projectTaskRepository.CreateAsync(projectTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||||
|
|
||||||
|
public class CreateProjectCommandValidator:AbstractValidator<CreateProjectCommand>
|
||||||
|
{
|
||||||
|
public CreateProjectCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Name)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("نام نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
RuleFor(y => y.Level)
|
||||||
|
.NotNull()
|
||||||
|
.IsInEnum();
|
||||||
|
When(x=>x.Level>ProjectHierarchyLevel.Project,()=>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.ParentId)
|
||||||
|
.NotNull()
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("شناسه والد نمیتواند خالی باشد");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProjectWithHierarchy;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command to create a new project with the new hierarchy structure
|
||||||
|
/// </summary>
|
||||||
|
public record CreateProjectWithHierarchyCommand(
|
||||||
|
string Name,
|
||||||
|
string? Description = null,
|
||||||
|
DateTime? PlannedStartDate = null,
|
||||||
|
DateTime? PlannedEndDate = null
|
||||||
|
) : IBaseCommand;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProjectWithHierarchy;
|
||||||
|
|
||||||
|
public class CreateProjectWithHierarchyCommandHandler : IRequestHandler<CreateProjectWithHierarchyCommand, OperationResult>
|
||||||
|
{
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public CreateProjectWithHierarchyCommandHandler(
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IUnitOfWork unitOfWork)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(CreateProjectWithHierarchyCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create new project
|
||||||
|
var project = new Project(request.Name, request.Description);
|
||||||
|
|
||||||
|
// Set planned dates if provided
|
||||||
|
if (request.PlannedStartDate.HasValue || request.PlannedEndDate.HasValue)
|
||||||
|
{
|
||||||
|
project.SetPlannedDates(request.PlannedStartDate, request.PlannedEndDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to repository
|
||||||
|
await _projectRepository.CreateAsync(project);
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return OperationResult.Failure($"خطا در ایجاد پروژه: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProjectWithHierarchy;
|
||||||
|
|
||||||
|
public class CreateProjectWithHierarchyCommandValidator : AbstractValidator<CreateProjectWithHierarchyCommand>
|
||||||
|
{
|
||||||
|
public CreateProjectWithHierarchyCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Name)
|
||||||
|
.NotEmpty().WithMessage("نام پروژه نمیتواند خالی باشد")
|
||||||
|
.MaximumLength(200).WithMessage("نام پروژه نمیتواند بیش از 200 کاراکتر باشد");
|
||||||
|
|
||||||
|
RuleFor(x => x.Description)
|
||||||
|
.MaximumLength(1000).WithMessage("توضیحات نمیتواند بیش از 1000 کاراکتر باشد")
|
||||||
|
.When(x => !string.IsNullOrEmpty(x.Description));
|
||||||
|
|
||||||
|
RuleFor(x => x)
|
||||||
|
.Must(x => x.PlannedStartDate == null || x.PlannedEndDate == null || x.PlannedStartDate <= x.PlannedEndDate)
|
||||||
|
.WithMessage("تاریخ شروع برنامهریزی شده نمیتواند بعد از تاریخ پایان برنامهریزی شده باشد");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.DeleteProject;
|
||||||
|
|
||||||
|
public record DeleteProjectCommand(Guid Id,ProjectHierarchyLevel Level) : IBaseCommand;
|
||||||
|
|
||||||
|
public class DeleteProjectCommandHandler : IBaseCommandHandler<DeleteProjectCommand>
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||||
|
private readonly IProjectTaskRepository _projectTaskRepository;
|
||||||
|
|
||||||
|
public DeleteProjectCommandHandler(
|
||||||
|
IUnitOfWork unitOfWork,
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IProjectPhaseRepository projectPhaseRepository,
|
||||||
|
IProjectTaskRepository projectTaskRepository)
|
||||||
|
{
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_projectPhaseRepository = projectPhaseRepository;
|
||||||
|
_projectTaskRepository = projectTaskRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(DeleteProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
await DeleteProject(request.Id);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
await DeleteProjectPhase(request.Id);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
await DeleteProjectTask(request.Id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteProject(Guid projectId)
|
||||||
|
{
|
||||||
|
var projectWithPhases = await _projectRepository.GetWithFullHierarchyAsync(projectId);
|
||||||
|
|
||||||
|
if (projectWithPhases == null)
|
||||||
|
throw new NotFoundException("پروژه یافت نشد");
|
||||||
|
|
||||||
|
// بررسی اینکه پروژه فاز یا زیرمجموعه دارد یا نه
|
||||||
|
if (projectWithPhases.Phases != null && projectWithPhases.Phases.Any())
|
||||||
|
throw new BadRequestException("نمیتوان پروژهای را حذف کرد که دارای فاز است. ابتدا تمام فازها را حذف کنید.");
|
||||||
|
|
||||||
|
_projectRepository.Remove(projectWithPhases);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteProjectPhase(Guid phaseId)
|
||||||
|
{
|
||||||
|
var phase = await _projectPhaseRepository.GetByIdAsync(phaseId);
|
||||||
|
|
||||||
|
if (phase == null)
|
||||||
|
throw new NotFoundException("فاز پروژه یافت نشد");
|
||||||
|
|
||||||
|
// بررسی اینکه فاز تسک یا زیرمجموعه دارد یا نه
|
||||||
|
var phaseWithTasks = await _projectPhaseRepository.GetWithTasksAsync(phaseId);
|
||||||
|
if (phaseWithTasks?.Tasks != null && phaseWithTasks.Tasks.Any())
|
||||||
|
throw new InvalidOperationException("نمیتوان فازی را حذف کرد که دارای تسک است. ابتدا تمام تسکها را حذف کنید.");
|
||||||
|
|
||||||
|
_projectPhaseRepository.Remove(phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteProjectTask(Guid taskId)
|
||||||
|
{
|
||||||
|
var task = await _projectTaskRepository.GetByIdAsync(taskId);
|
||||||
|
|
||||||
|
if (task == null)
|
||||||
|
throw new NotFoundException("تسک یافت نشد");
|
||||||
|
|
||||||
|
// حذف خود تسک
|
||||||
|
_projectTaskRepository.Remove(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.DeleteProject;
|
||||||
|
|
||||||
|
public class DeleteProjectCommandValidator:AbstractValidator<DeleteProjectCommand>
|
||||||
|
{
|
||||||
|
public DeleteProjectCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x=>x.Id)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه پروژه نمیتواند خالی باشد.");
|
||||||
|
RuleFor(x=>x.Level)
|
||||||
|
.IsInEnum()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("سطح حذف پروژه نامعتبر است.");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.EditProject;
|
||||||
|
|
||||||
|
public record EditProjectCommand(string Name, Guid Id, ProjectHierarchyLevel Level): IBaseCommand;
|
||||||
|
public class EditProjectCommandHandler: IBaseCommandHandler<EditProjectCommand>
|
||||||
|
{
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||||
|
private readonly IProjectTaskRepository _projectTaskRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public EditProjectCommandHandler(
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IProjectPhaseRepository projectPhaseRepository,
|
||||||
|
IProjectTaskRepository projectTaskRepository,
|
||||||
|
IUnitOfWork unitOfWork)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_projectPhaseRepository = projectPhaseRepository;
|
||||||
|
_projectTaskRepository = projectTaskRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(EditProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
await EditProject(request);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
await EditProjectPhase(request);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
await EditProjectTask(request);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EditProject(EditProjectCommand request)
|
||||||
|
{
|
||||||
|
var project = await _projectRepository.GetByIdAsync(request.Id);
|
||||||
|
|
||||||
|
if (project == null)
|
||||||
|
throw new NotFoundException("پروژه یافت نشد");
|
||||||
|
|
||||||
|
project.UpdateName(request.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EditProjectPhase(EditProjectCommand request)
|
||||||
|
{
|
||||||
|
var phase = await _projectPhaseRepository.GetByIdAsync(request.Id);
|
||||||
|
|
||||||
|
if (phase == null)
|
||||||
|
throw new NotFoundException("فاز پروژه یافت نشد");
|
||||||
|
|
||||||
|
phase.UpdateName(request.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EditProjectTask(EditProjectCommand request)
|
||||||
|
{
|
||||||
|
var task = await _projectTaskRepository.GetByIdAsync(request.Id);
|
||||||
|
|
||||||
|
if (task == null)
|
||||||
|
throw new NotFoundException("تسک یافت نشد");
|
||||||
|
|
||||||
|
task.UpdateName(request.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.EditProject;
|
||||||
|
|
||||||
|
public class EditProjectCommandValidator:AbstractValidator<EditProjectCommand>
|
||||||
|
{
|
||||||
|
public EditProjectCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Name)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("نام پروژه نمیتواند خالی باشد.");
|
||||||
|
|
||||||
|
RuleFor(x=>x.Id)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull().WithMessage("شناسه پروژه نمیتواند خالی باشد.");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||||
|
|
||||||
|
public record SetTimeProjectCommand(List<SetTimeProjectSectionItem> SectionItems, Guid Id, ProjectHierarchyLevel Level):IBaseCommand;
|
||||||
|
|
||||||
|
public class SetTimeSectionTime
|
||||||
|
{
|
||||||
|
public string Description { get; set; }
|
||||||
|
public int Hours { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||||
|
|
||||||
|
public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectCommand>
|
||||||
|
{
|
||||||
|
private readonly IProjectRepository _projectRepository;
|
||||||
|
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||||
|
private readonly IProjectTaskRepository _projectTaskRepository;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly IAuthHelper _authHelper;
|
||||||
|
private long? _userId;
|
||||||
|
|
||||||
|
|
||||||
|
public SetTimeProjectCommandHandler(
|
||||||
|
IProjectRepository projectRepository,
|
||||||
|
IProjectPhaseRepository projectPhaseRepository,
|
||||||
|
IProjectTaskRepository projectTaskRepository,
|
||||||
|
IUnitOfWork unitOfWork, IAuthHelper authHelper)
|
||||||
|
{
|
||||||
|
_projectRepository = projectRepository;
|
||||||
|
_projectPhaseRepository = projectPhaseRepository;
|
||||||
|
_projectTaskRepository = projectTaskRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
_authHelper = authHelper;
|
||||||
|
_userId = authHelper.GetCurrentUserId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
return await SetTimeForProjectTask(request, cancellationToken);
|
||||||
|
default:
|
||||||
|
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> SetTimeForProject(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var project = await _projectRepository.GetWithFullHierarchyAsync(request.Id);
|
||||||
|
if (project == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("پروژه یافت نشد");
|
||||||
|
return OperationResult.NotFound("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
||||||
|
}
|
||||||
|
|
||||||
|
long? addedByUserId = _userId;
|
||||||
|
|
||||||
|
// تنظیم زمان برای تمام sections در تمام فازها و تسکهای پروژه
|
||||||
|
foreach (var phase in project.Phases)
|
||||||
|
{
|
||||||
|
foreach (var task in phase.Tasks)
|
||||||
|
{
|
||||||
|
foreach (var section in task.Sections)
|
||||||
|
{
|
||||||
|
var sectionItem = request.SectionItems.FirstOrDefault(si => si.SectionId == section.Id);
|
||||||
|
if (sectionItem != null)
|
||||||
|
{
|
||||||
|
SetSectionTime(section, sectionItem, addedByUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> SetTimeForProjectPhase(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var phase = await _projectPhaseRepository.GetWithTasksAsync(request.Id);
|
||||||
|
if (phase == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("فاز پروژه یافت نشد");
|
||||||
|
return OperationResult.NotFound("<22><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
||||||
|
}
|
||||||
|
|
||||||
|
long? addedByUserId = _userId;
|
||||||
|
|
||||||
|
// تنظیم زمان برای تمام sections در تمام تسکهای این فاز
|
||||||
|
foreach (var task in phase.Tasks)
|
||||||
|
{
|
||||||
|
foreach (var section in task.Sections)
|
||||||
|
{
|
||||||
|
var sectionItem = request.SectionItems.FirstOrDefault(si => si.SectionId == section.Id);
|
||||||
|
if (sectionItem != null)
|
||||||
|
{
|
||||||
|
SetSectionTime(section, sectionItem, addedByUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult> SetTimeForProjectTask(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var task = await _projectTaskRepository.GetWithSectionsAsync(request.Id);
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("تسک یافت نشد");
|
||||||
|
return OperationResult.NotFound("<22>Ә <20><><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
||||||
|
}
|
||||||
|
|
||||||
|
long? addedByUserId = _userId;
|
||||||
|
|
||||||
|
// تنظیم زمان مستقیماً برای sections این تسک
|
||||||
|
foreach (var section in task.Sections)
|
||||||
|
{
|
||||||
|
var sectionItem = request.SectionItems.FirstOrDefault(si => si.SectionId == section.Id);
|
||||||
|
if (sectionItem != null)
|
||||||
|
{
|
||||||
|
SetSectionTime(section, sectionItem, addedByUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSectionTime(TaskSection section, SetTimeProjectSectionItem sectionItem, long? addedByUserId)
|
||||||
|
{
|
||||||
|
var initData = sectionItem.InitData;
|
||||||
|
var initialTime = TimeSpan.FromHours(initData.Hours);
|
||||||
|
|
||||||
|
// تنظیم زمان اولیه
|
||||||
|
section.UpdateInitialEstimatedHours(initialTime, initData.Description);
|
||||||
|
|
||||||
|
section.ClearAdditionalTimes();
|
||||||
|
// افزودن زمانهای اضافی
|
||||||
|
foreach (var additionalTime in sectionItem.AdditionalTime)
|
||||||
|
{
|
||||||
|
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours);
|
||||||
|
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void SetSectionTime(ProjectSection section, SetTimeProjectSectionItem sectionItem, long? addedByUserId)
|
||||||
|
// {
|
||||||
|
// var initData = sectionItem.InitData;
|
||||||
|
// var initialTime = TimeSpan.FromHours(initData.Hours);
|
||||||
|
//
|
||||||
|
// // تنظیم زمان اولیه
|
||||||
|
// section.UpdateInitialEstimatedHours(initialTime, initData.Description);
|
||||||
|
//
|
||||||
|
// section.ClearAdditionalTimes();
|
||||||
|
// // افزودن زمانهای اضافی
|
||||||
|
// foreach (var additionalTime in sectionItem.AdditionalTime)
|
||||||
|
// {
|
||||||
|
// var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours);
|
||||||
|
// section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||||
|
|
||||||
|
public class SetTimeProjectCommandValidator:AbstractValidator<SetTimeProjectCommand>
|
||||||
|
{
|
||||||
|
public SetTimeProjectCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x=>x.Id)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه پروژه نمیتواند خالی باشد.");
|
||||||
|
|
||||||
|
RuleForEach(x => x.SectionItems)
|
||||||
|
.SetValidator(command => new SetTimeProjectSectionItemValidator());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class SetTimeProjectSectionItemValidator:AbstractValidator<SetTimeProjectSectionItem>
|
||||||
|
{
|
||||||
|
public SetTimeProjectSectionItemValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x=>x.SectionId)
|
||||||
|
.NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("شناسه بخش نمیتواند خالی باشد.");
|
||||||
|
|
||||||
|
RuleFor(x=>x.InitData)
|
||||||
|
.SetValidator(new TimeDataValidator());
|
||||||
|
|
||||||
|
RuleForEach(x=>x.AdditionalTime)
|
||||||
|
.SetValidator(new TimeDataValidator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TimeDataValidator : AbstractValidator<SetTimeSectionTime>
|
||||||
|
{
|
||||||
|
public TimeDataValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Hours)
|
||||||
|
.GreaterThanOrEqualTo(0)
|
||||||
|
.WithMessage("ساعت نمیتواند منفی باشد.");
|
||||||
|
|
||||||
|
RuleFor(x=>x.Description)
|
||||||
|
.MaximumLength(500)
|
||||||
|
.WithMessage("توضیحات نمیتواند بیشتر از 500 کاراکتر باشد.");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.TransferSection;
|
||||||
|
|
||||||
|
public record TransferSectionCommand : IBaseCommand
|
||||||
|
{
|
||||||
|
public Guid SectionId { get; set; }
|
||||||
|
public long FromUserId { get; set; }
|
||||||
|
public long ToUserId { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.TransferSection;
|
||||||
|
|
||||||
|
public class TransferSectionCommandHandler : IBaseCommandHandler<TransferSectionCommand>
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly ITaskSectionRepository _taskSectionRepository;
|
||||||
|
private readonly IUserRepository _userRepository;
|
||||||
|
|
||||||
|
public TransferSectionCommandHandler(
|
||||||
|
ITaskSectionRepository taskSectionRepository,
|
||||||
|
IUserRepository userRepository,
|
||||||
|
IUnitOfWork unitOfWork)
|
||||||
|
{
|
||||||
|
_taskSectionRepository = taskSectionRepository;
|
||||||
|
_userRepository = userRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult> Handle(TransferSectionCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// دریافت section با activities
|
||||||
|
var section = await _taskSectionRepository.GetByIdWithActivitiesAsync(request.SectionId, cancellationToken);
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound("بخش پروژه یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// بررسی وجود کاربر مبدا
|
||||||
|
var fromUser = await _userRepository.GetByIdAsync(request.FromUserId);
|
||||||
|
if (fromUser == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound($"کاربر مبدا با شناسه {request.FromUserId} یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// بررسی وجود کاربر مقصد
|
||||||
|
var toUser = await _userRepository.GetByIdAsync(request.ToUserId);
|
||||||
|
if (toUser == null)
|
||||||
|
{
|
||||||
|
return OperationResult.NotFound($"کاربر مقصد با شناسه {request.ToUserId} یافت نشد");
|
||||||
|
}
|
||||||
|
|
||||||
|
// بررسی اینکه کاربر مبدا و مقصد یکسان نباشند
|
||||||
|
if (request.FromUserId == request.ToUserId)
|
||||||
|
{
|
||||||
|
return OperationResult.Failure("کاربر مبدا و مقصد نمیتوانند یکسان باشند");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// انتقال به کاربر جدید
|
||||||
|
section.TransferToUser(request.FromUserId, request.ToUserId);
|
||||||
|
|
||||||
|
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return OperationResult.Success();
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return OperationResult.Failure(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.TransferSection;
|
||||||
|
|
||||||
|
public class TransferSectionCommandValidator : AbstractValidator<TransferSectionCommand>
|
||||||
|
{
|
||||||
|
public TransferSectionCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.SectionId)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("شناسه بخش نمیتواند خالی باشد");
|
||||||
|
|
||||||
|
RuleFor(x => x.FromUserId)
|
||||||
|
.NotEmpty()
|
||||||
|
.GreaterThan(0)
|
||||||
|
.WithMessage("شناسه کاربر مبدا نمیتواند خالی یا صفر باشد");
|
||||||
|
|
||||||
|
RuleFor(x => x.ToUserId)
|
||||||
|
.NotEmpty()
|
||||||
|
.GreaterThan(0)
|
||||||
|
.WithMessage("شناسه کاربر مقصد نمیتواند خالی یا صفر باشد");
|
||||||
|
|
||||||
|
RuleFor(x => x)
|
||||||
|
.Must(x => x.FromUserId != x.ToUserId)
|
||||||
|
.WithMessage("کاربر مبدا و مقصد نمیتوانند یکسان باشند");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Project entity
|
||||||
|
/// </summary>
|
||||||
|
public class ProjectDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public DateTime CreationDate { get; set; }
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public DateTime? PlannedStartDate { get; set; }
|
||||||
|
public DateTime? PlannedEndDate { get; set; }
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public TimeSpan? AllocatedTime { get; set; }
|
||||||
|
public bool HasTimeOverride { get; set; }
|
||||||
|
public bool HasAssignmentOverride { get; set; }
|
||||||
|
public TimeSpan TotalTimeSpent { get; set; }
|
||||||
|
public TimeSpan TotalEstimatedTime { get; set; }
|
||||||
|
|
||||||
|
public List<ProjectPhaseDto> Phases { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for ProjectPhase entity
|
||||||
|
/// </summary>
|
||||||
|
public class ProjectPhaseDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public DateTime CreationDate { get; set; }
|
||||||
|
public Guid ProjectId { get; set; }
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public int OrderIndex { get; set; }
|
||||||
|
public TimeSpan? AllocatedTime { get; set; }
|
||||||
|
public bool HasTimeOverride { get; set; }
|
||||||
|
public bool HasAssignmentOverride { get; set; }
|
||||||
|
public TimeSpan TotalTimeSpent { get; set; }
|
||||||
|
public TimeSpan TotalEstimatedTime { get; set; }
|
||||||
|
|
||||||
|
public List<ProjectTaskDto> Tasks { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for ProjectTask entity
|
||||||
|
/// </summary>
|
||||||
|
public class ProjectTaskDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public DateTime CreationDate { get; set; }
|
||||||
|
public Guid PhaseId { get; set; }
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public string Priority { get; set; } = string.Empty;
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public DateTime? DueDate { get; set; }
|
||||||
|
public int OrderIndex { get; set; }
|
||||||
|
public TimeSpan? AllocatedTime { get; set; }
|
||||||
|
public bool HasTimeOverride { get; set; }
|
||||||
|
public bool HasAssignmentOverride { get; set; }
|
||||||
|
public TimeSpan TotalTimeSpent { get; set; }
|
||||||
|
public TimeSpan TotalEstimatedTime { get; set; }
|
||||||
|
|
||||||
|
public List<ProjectSectionDto> Sections { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for TaskSection entity
|
||||||
|
/// </summary>
|
||||||
|
public class ProjectSectionDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid TaskId { get; set; }
|
||||||
|
public Guid SkillId { get; set; }
|
||||||
|
public string SkillName { get; set; } = string.Empty;
|
||||||
|
public TimeSpan InitialEstimatedHours { get; set; }
|
||||||
|
public string? InitialDescription { get; set; }
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public long CurrentAssignedUserId { get; set; }
|
||||||
|
public string? CurrentAssignedUserName { get; set; }
|
||||||
|
public DateTime CreationDate { get; set; }
|
||||||
|
|
||||||
|
public TimeSpan FinalEstimatedHours { get; set; }
|
||||||
|
public TimeSpan TotalTimeSpent { get; set; }
|
||||||
|
public bool IsCompleted { get; set; }
|
||||||
|
public bool IsInProgress { get; set; }
|
||||||
|
|
||||||
|
public List<TaskSectionActivityDto> Activities { get; set; } = new();
|
||||||
|
public List<TaskSectionAdditionalTimeDto> AdditionalTimes { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for ProjectSectionActivity entity
|
||||||
|
/// </summary>
|
||||||
|
public class TaskSectionActivityDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SectionId { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string? UserName { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
public string? EndNotes { get; set; }
|
||||||
|
public bool IsActive { get; set; }
|
||||||
|
public TimeSpan TimeSpent { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for ProjectSectionAdditionalTime entity
|
||||||
|
/// </summary>
|
||||||
|
public class TaskSectionAdditionalTimeDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public TimeSpan Hours { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public long? AddedByUserId { get; set; }
|
||||||
|
public string? AddedByUserName { get; set; }
|
||||||
|
public DateTime AddedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
|
||||||
|
public class SetTimeProjectSectionItem
|
||||||
|
{
|
||||||
|
public Guid SectionId { get; set; }
|
||||||
|
public SetTimeSectionTime InitData { get; set; }
|
||||||
|
public List<SetTimeSectionTime> AdditionalTime { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Extensions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mapping extensions for project hierarchy entities to DTOs
|
||||||
|
/// </summary>
|
||||||
|
public static class ProjectMappingExtensions
|
||||||
|
{
|
||||||
|
#region Project Mappings
|
||||||
|
|
||||||
|
public static ProjectDto ToDto(this Project project)
|
||||||
|
{
|
||||||
|
return new ProjectDto
|
||||||
|
{
|
||||||
|
Id = project.Id,
|
||||||
|
Name = project.Name,
|
||||||
|
Description = project.Description,
|
||||||
|
CreationDate = project.CreationDate,
|
||||||
|
StartDate = project.StartDate,
|
||||||
|
EndDate = project.EndDate,
|
||||||
|
PlannedStartDate = project.PlannedStartDate,
|
||||||
|
PlannedEndDate = project.PlannedEndDate,
|
||||||
|
Status = project.Status.ToString(),
|
||||||
|
HasAssignmentOverride = project.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = project.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = project.GetTotalEstimatedTime(),
|
||||||
|
Phases = project.Phases.Select(p => p.ToDto()).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectDto ToSummaryDto(this Project project)
|
||||||
|
{
|
||||||
|
return new ProjectDto
|
||||||
|
{
|
||||||
|
Id = project.Id,
|
||||||
|
Name = project.Name,
|
||||||
|
Description = project.Description,
|
||||||
|
CreationDate = project.CreationDate,
|
||||||
|
StartDate = project.StartDate,
|
||||||
|
EndDate = project.EndDate,
|
||||||
|
PlannedStartDate = project.PlannedStartDate,
|
||||||
|
PlannedEndDate = project.PlannedEndDate,
|
||||||
|
Status = project.Status.ToString(),
|
||||||
|
HasAssignmentOverride = project.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = project.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = project.GetTotalEstimatedTime()
|
||||||
|
// No phases for summary
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Phase Mappings
|
||||||
|
|
||||||
|
public static ProjectPhaseDto ToDto(this ProjectPhase phase)
|
||||||
|
{
|
||||||
|
return new ProjectPhaseDto
|
||||||
|
{
|
||||||
|
Id = phase.Id,
|
||||||
|
Name = phase.Name,
|
||||||
|
Description = phase.Description,
|
||||||
|
CreationDate = phase.CreationDate,
|
||||||
|
ProjectId = phase.ProjectId,
|
||||||
|
Status = phase.Status.ToString(),
|
||||||
|
StartDate = phase.StartDate,
|
||||||
|
EndDate = phase.EndDate,
|
||||||
|
OrderIndex = phase.OrderIndex,
|
||||||
|
HasAssignmentOverride = phase.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = phase.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = phase.GetTotalEstimatedTime(),
|
||||||
|
Tasks = phase.Tasks.Select(t => t.ToDto()).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectPhaseDto ToSummaryDto(this ProjectPhase phase)
|
||||||
|
{
|
||||||
|
return new ProjectPhaseDto
|
||||||
|
{
|
||||||
|
Id = phase.Id,
|
||||||
|
Name = phase.Name,
|
||||||
|
Description = phase.Description,
|
||||||
|
CreationDate = phase.CreationDate,
|
||||||
|
ProjectId = phase.ProjectId,
|
||||||
|
Status = phase.Status.ToString(),
|
||||||
|
StartDate = phase.StartDate,
|
||||||
|
EndDate = phase.EndDate,
|
||||||
|
OrderIndex = phase.OrderIndex,
|
||||||
|
HasAssignmentOverride = phase.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = phase.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = phase.GetTotalEstimatedTime()
|
||||||
|
// No tasks for summary
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Task Mappings
|
||||||
|
|
||||||
|
public static ProjectTaskDto ToDto(this ProjectTask task)
|
||||||
|
{
|
||||||
|
return new ProjectTaskDto
|
||||||
|
{
|
||||||
|
Id = task.Id,
|
||||||
|
Name = task.Name,
|
||||||
|
Description = task.Description,
|
||||||
|
CreationDate = task.CreationDate,
|
||||||
|
PhaseId = task.PhaseId,
|
||||||
|
Status = task.Status.ToString(),
|
||||||
|
Priority = task.Priority.ToString(),
|
||||||
|
StartDate = task.StartDate,
|
||||||
|
EndDate = task.EndDate,
|
||||||
|
DueDate = task.DueDate,
|
||||||
|
OrderIndex = task.OrderIndex,
|
||||||
|
AllocatedTime = task.AllocatedTime,
|
||||||
|
HasTimeOverride = task.HasTimeOverride,
|
||||||
|
HasAssignmentOverride = task.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = task.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = task.GetTotalEstimatedTime(),
|
||||||
|
Sections = task.Sections.Select(s => s.ToDto()).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectTaskDto ToSummaryDto(this ProjectTask task)
|
||||||
|
{
|
||||||
|
return new ProjectTaskDto
|
||||||
|
{
|
||||||
|
Id = task.Id,
|
||||||
|
Name = task.Name,
|
||||||
|
Description = task.Description,
|
||||||
|
CreationDate = task.CreationDate,
|
||||||
|
PhaseId = task.PhaseId,
|
||||||
|
Status = task.Status.ToString(),
|
||||||
|
Priority = task.Priority.ToString(),
|
||||||
|
StartDate = task.StartDate,
|
||||||
|
EndDate = task.EndDate,
|
||||||
|
DueDate = task.DueDate,
|
||||||
|
OrderIndex = task.OrderIndex,
|
||||||
|
AllocatedTime = task.AllocatedTime,
|
||||||
|
HasTimeOverride = task.HasTimeOverride,
|
||||||
|
HasAssignmentOverride = task.HasAssignmentOverride,
|
||||||
|
TotalTimeSpent = task.GetTotalTimeSpent(),
|
||||||
|
TotalEstimatedTime = task.GetTotalEstimatedTime()
|
||||||
|
// No sections for summary
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Section Mappings
|
||||||
|
|
||||||
|
public static ProjectSectionDto ToDto(this TaskSection section)
|
||||||
|
{
|
||||||
|
return new ProjectSectionDto
|
||||||
|
{
|
||||||
|
Id = section.Id,
|
||||||
|
TaskId = section.TaskId,
|
||||||
|
SkillId = section.SkillId,
|
||||||
|
SkillName = section.Skill?.Name ?? string.Empty,
|
||||||
|
InitialEstimatedHours = section.InitialEstimatedHours,
|
||||||
|
InitialDescription = section.InitialDescription,
|
||||||
|
Status = section.Status.ToString(),
|
||||||
|
CurrentAssignedUserId = section.CurrentAssignedUserId,
|
||||||
|
CreationDate = section.CreationDate,
|
||||||
|
FinalEstimatedHours = section.FinalEstimatedHours,
|
||||||
|
TotalTimeSpent = section.GetTotalTimeSpent(),
|
||||||
|
IsCompleted = section.IsCompleted(),
|
||||||
|
IsInProgress = section.IsInProgress(),
|
||||||
|
Activities = section.Activities.Select(a => a.ToDto()).ToList(),
|
||||||
|
AdditionalTimes = section.AdditionalTimes.Select(at => at.ToDto()).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectSectionDto ToSummaryDto(this TaskSection section)
|
||||||
|
{
|
||||||
|
return new ProjectSectionDto
|
||||||
|
{
|
||||||
|
Id = section.Id,
|
||||||
|
TaskId = section.TaskId,
|
||||||
|
SkillId = section.SkillId,
|
||||||
|
SkillName = section.Skill?.Name ?? string.Empty,
|
||||||
|
InitialEstimatedHours = section.InitialEstimatedHours,
|
||||||
|
InitialDescription = section.InitialDescription,
|
||||||
|
Status = section.Status.ToString(),
|
||||||
|
CurrentAssignedUserId = section.CurrentAssignedUserId,
|
||||||
|
CreationDate = section.CreationDate,
|
||||||
|
FinalEstimatedHours = section.FinalEstimatedHours,
|
||||||
|
TotalTimeSpent = section.GetTotalTimeSpent(),
|
||||||
|
IsCompleted = section.IsCompleted(),
|
||||||
|
IsInProgress = section.IsInProgress()
|
||||||
|
// No activities or additional times for summary
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Activity Mappings
|
||||||
|
|
||||||
|
public static TaskSectionActivityDto ToDto(this TaskSectionActivity activity)
|
||||||
|
{
|
||||||
|
return new TaskSectionActivityDto
|
||||||
|
{
|
||||||
|
Id = activity.Id,
|
||||||
|
SectionId = activity.SectionId,
|
||||||
|
UserId = activity.UserId,
|
||||||
|
StartDate = activity.StartDate,
|
||||||
|
EndDate = activity.EndDate,
|
||||||
|
Notes = activity.Notes,
|
||||||
|
EndNotes = activity.EndNotes,
|
||||||
|
IsActive = activity.IsActive,
|
||||||
|
TimeSpent = activity.GetTimeSpent()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Additional Time Mappings
|
||||||
|
|
||||||
|
public static TaskSectionAdditionalTimeDto ToDto(this TaskSectionAdditionalTime additionalTime)
|
||||||
|
{
|
||||||
|
return new TaskSectionAdditionalTimeDto
|
||||||
|
{
|
||||||
|
Id = additionalTime.Id,
|
||||||
|
Hours = additionalTime.Hours,
|
||||||
|
Reason = additionalTime.Reason,
|
||||||
|
AddedByUserId = additionalTime.AddedByUserId,
|
||||||
|
AddedAt = additionalTime.AddedAt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Collection Mappings
|
||||||
|
|
||||||
|
public static List<ProjectDto> ToSummaryDtos(this IEnumerable<Project> projects)
|
||||||
|
{
|
||||||
|
return projects.Select(p => p.ToSummaryDto()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ProjectPhaseDto> ToSummaryDtos(this IEnumerable<ProjectPhase> phases)
|
||||||
|
{
|
||||||
|
return phases.Select(p => p.ToSummaryDto()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ProjectTaskDto> ToSummaryDtos(this IEnumerable<ProjectTask> tasks)
|
||||||
|
{
|
||||||
|
return tasks.Select(t => t.ToSummaryDto()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ProjectSectionDto> ToSummaryDtos(this IEnumerable<TaskSection> sections)
|
||||||
|
{
|
||||||
|
return sections.Select(s => s.ToSummaryDto()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectAssignDetails;
|
||||||
|
|
||||||
|
public record GetProjectAssignDetailsResponse(List<GetProjectAssignSectionDetails> Items);
|
||||||
|
|
||||||
|
public record GetProjectAssignSectionDetails(string Skill,Guid SkillId,Guid? SectionId,long UserId);
|
||||||
|
|
||||||
|
public record GetProjectAssignDetailsQuery(Guid Id,ProjectHierarchyLevel Level) : IBaseQuery<GetProjectAssignDetailsResponse>;
|
||||||
|
|
||||||
|
public class GetProjectAssignDetailsQueryHandler:IBaseQueryHandler<GetProjectAssignDetailsQuery,GetProjectAssignDetailsResponse>
|
||||||
|
{
|
||||||
|
private readonly IProgramManagerDbContext _dbContext;
|
||||||
|
|
||||||
|
public GetProjectAssignDetailsQueryHandler(IProgramManagerDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<GetProjectAssignDetailsResponse>> Handle(GetProjectAssignDetailsQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
switch (request.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
return await GetProjectAssignDetails(request.Id, cancellationToken);
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
return await GetPhaseAssignDetails(request.Id, cancellationToken);
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
return await GetTaskAssignDetails(request.Id, cancellationToken);
|
||||||
|
default:
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Failure("سطح پروژه نامعتبر است");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult<GetProjectAssignDetailsResponse>> GetProjectAssignDetails(Guid projectId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// گرفتن تمام فازهای پروژه
|
||||||
|
|
||||||
|
var skills = _dbContext.Skills.ToList();
|
||||||
|
var sectionsData =await _dbContext.ProjectSections
|
||||||
|
.Where(p => p.ProjectId == projectId).ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (skills.Count == 0)
|
||||||
|
{
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(new GetProjectAssignDetailsResponse(new List<GetProjectAssignSectionDetails>()));
|
||||||
|
}
|
||||||
|
var sections = skills.Select(x=>
|
||||||
|
{
|
||||||
|
var section = sectionsData.FirstOrDefault(s => s.SkillId == x.Id);
|
||||||
|
|
||||||
|
return new GetProjectAssignSectionDetails(
|
||||||
|
x.Name,
|
||||||
|
x.Id,
|
||||||
|
section?.Id,
|
||||||
|
section?.UserId ?? 0
|
||||||
|
);
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
var response = new GetProjectAssignDetailsResponse(sections);
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult<GetProjectAssignDetailsResponse>> GetPhaseAssignDetails(Guid phaseId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var skills = _dbContext.Skills.ToList();
|
||||||
|
|
||||||
|
var sectionsData =await _dbContext.PhaseSections
|
||||||
|
.Where(p => p.PhaseId == phaseId)
|
||||||
|
.ToListAsync(cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
if (skills.Count == 0)
|
||||||
|
{
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(new GetProjectAssignDetailsResponse(new List<GetProjectAssignSectionDetails>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
var sections = skills.Select(x=>
|
||||||
|
{
|
||||||
|
var section = sectionsData.FirstOrDefault(s => s.SkillId == x.Id);
|
||||||
|
|
||||||
|
return new GetProjectAssignSectionDetails(
|
||||||
|
x.Name,
|
||||||
|
x.Id,
|
||||||
|
section?.Id,
|
||||||
|
section?.UserId ?? 0
|
||||||
|
);
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var response = new GetProjectAssignDetailsResponse(sections);
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<OperationResult<GetProjectAssignDetailsResponse>> GetTaskAssignDetails(Guid taskId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var skills = _dbContext.Skills.ToList();
|
||||||
|
var sectionsData =await _dbContext.TaskSections
|
||||||
|
.Where(p => p.TaskId == taskId).ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (skills.Count == 0)
|
||||||
|
{
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(new GetProjectAssignDetailsResponse(new List<GetProjectAssignSectionDetails>()));
|
||||||
|
}
|
||||||
|
var sections = skills.Select(x=>
|
||||||
|
{
|
||||||
|
var section = sectionsData.FirstOrDefault(s => s.SkillId == x.Id);
|
||||||
|
|
||||||
|
return new GetProjectAssignSectionDetails(
|
||||||
|
x.Name,
|
||||||
|
x.Id,
|
||||||
|
section?.Id,
|
||||||
|
section?.OriginalAssignedUserId ?? 0
|
||||||
|
);
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var response = new GetProjectAssignDetailsResponse(sections);
|
||||||
|
return OperationResult<GetProjectAssignDetailsResponse>.Success(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
|
public record GetProjectListDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; init; }
|
||||||
|
public string Name { get; init; } = string.Empty;
|
||||||
|
public int Percentage { get; init; }
|
||||||
|
public ProjectHierarchyLevel Level { get; init; }
|
||||||
|
public Guid? ParentId { get; init; }
|
||||||
|
public bool HasFront { get; set; }
|
||||||
|
public bool HasBackend { get; set; }
|
||||||
|
public bool HasDesign { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
|
|
||||||
|
public record GetProjectsListQuery(ProjectHierarchyLevel HierarchyLevel,
|
||||||
|
Guid? ParentId) : IBaseQuery<GetProjectsListResponse>;
|
||||||
|
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
|
|
||||||
|
public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuery, GetProjectsListResponse>
|
||||||
|
{
|
||||||
|
private readonly IProgramManagerDbContext _context;
|
||||||
|
|
||||||
|
public GetProjectsListQueryHandler(IProgramManagerDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OperationResult<GetProjectsListResponse>> Handle(GetProjectsListQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
List<GetProjectListDto> projects;
|
||||||
|
|
||||||
|
switch (request.HierarchyLevel)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
projects = await GetProjects(request.ParentId, cancellationToken);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
projects = await GetPhases(request.ParentId, cancellationToken);
|
||||||
|
break;
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
projects = await GetTasks(request.ParentId, cancellationToken);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return OperationResult<GetProjectsListResponse>.Failure("سطح سلسله مراتب نامعتبر است");
|
||||||
|
}
|
||||||
|
await SetSkillFlags(projects, cancellationToken);
|
||||||
|
|
||||||
|
var response = new GetProjectsListResponse(projects);
|
||||||
|
return OperationResult<GetProjectsListResponse>.Success(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<List<GetProjectListDto>> GetProjects(Guid? parentId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.Projects.AsQueryable();
|
||||||
|
|
||||||
|
// پروژهها سطح بالا هستند و parentId ندارند، فقط در صورت null بودن parentId نمایش داده میشوند
|
||||||
|
if (parentId.HasValue)
|
||||||
|
{
|
||||||
|
return new List<GetProjectListDto>(); // پروژهها parent ندارند
|
||||||
|
}
|
||||||
|
|
||||||
|
var projects = await query
|
||||||
|
.OrderByDescending(p => p.CreationDate)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
var result = new List<GetProjectListDto>();
|
||||||
|
|
||||||
|
foreach (var project in projects)
|
||||||
|
{
|
||||||
|
var percentage = await CalculateProjectPercentage(project, cancellationToken);
|
||||||
|
result.Add(new GetProjectListDto
|
||||||
|
{
|
||||||
|
Id = project.Id,
|
||||||
|
Name = project.Name,
|
||||||
|
Level = ProjectHierarchyLevel.Project,
|
||||||
|
ParentId = null,
|
||||||
|
Percentage = percentage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<List<GetProjectListDto>> GetPhases(Guid? parentId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.ProjectPhases.AsQueryable();
|
||||||
|
|
||||||
|
if (parentId.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.ProjectId == parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var phases = await query
|
||||||
|
.OrderByDescending(p => p.CreationDate)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
var result = new List<GetProjectListDto>();
|
||||||
|
|
||||||
|
foreach (var phase in phases)
|
||||||
|
{
|
||||||
|
var percentage = await CalculatePhasePercentage(phase, cancellationToken);
|
||||||
|
result.Add(new GetProjectListDto
|
||||||
|
{
|
||||||
|
Id = phase.Id,
|
||||||
|
Name = phase.Name,
|
||||||
|
Level = ProjectHierarchyLevel.Phase,
|
||||||
|
ParentId = phase.ProjectId,
|
||||||
|
Percentage = percentage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<List<GetProjectListDto>> GetTasks(Guid? parentId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.ProjectTasks.AsQueryable();
|
||||||
|
|
||||||
|
if (parentId.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.PhaseId == parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var tasks = await query
|
||||||
|
.OrderByDescending(t => t.CreationDate)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
var result = new List<GetProjectListDto>();
|
||||||
|
|
||||||
|
foreach (var task in tasks)
|
||||||
|
{
|
||||||
|
var percentage = await CalculateTaskPercentage(task, cancellationToken);
|
||||||
|
result.Add(new GetProjectListDto
|
||||||
|
{
|
||||||
|
Id = task.Id,
|
||||||
|
Name = task.Name,
|
||||||
|
Level = ProjectHierarchyLevel.Task,
|
||||||
|
ParentId = task.PhaseId,
|
||||||
|
Percentage = percentage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetSkillFlags(List<GetProjectListDto> projects, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var projectIds = projects.Select(x => x.Id).ToList();
|
||||||
|
|
||||||
|
// تنها تسکها sections دارند، بنابراین برای سطوح مختلف باید متفاوت عمل کنیم
|
||||||
|
List<Guid> taskIds;
|
||||||
|
|
||||||
|
switch (projects.FirstOrDefault()?.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
// برای پروژهها، باید تمام تسکهای زیرمجموعه را پیدا کنیم
|
||||||
|
var phaseIds = await _context.ProjectPhases
|
||||||
|
.Where(ph => projectIds.Contains(ph.ProjectId))
|
||||||
|
.Select(ph => ph.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
taskIds = await _context.ProjectTasks
|
||||||
|
.Where(t => phaseIds.Contains(t.PhaseId))
|
||||||
|
.Select(t => t.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
// برای فازها، تمام تسکهای آن فازها را پیدا کنیم
|
||||||
|
taskIds = await _context.ProjectTasks
|
||||||
|
.Where(t => projectIds.Contains(t.PhaseId))
|
||||||
|
.Select(t => t.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
// برای تسکها، خود آنها taskIds هستند
|
||||||
|
taskIds = projectIds;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!taskIds.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var sections = await _context.TaskSections
|
||||||
|
.Include(x => x.Skill)
|
||||||
|
.Where(x => taskIds.Contains(x.TaskId))
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
foreach (var project in projects)
|
||||||
|
{
|
||||||
|
List<Guid> relevantTaskIds;
|
||||||
|
|
||||||
|
switch (project.Level)
|
||||||
|
{
|
||||||
|
case ProjectHierarchyLevel.Project:
|
||||||
|
// برای پروژه، تمام تسکهای زیرمجموعه
|
||||||
|
var projectPhaseIds = await _context.ProjectPhases
|
||||||
|
.Where(ph => ph.ProjectId == project.Id)
|
||||||
|
.Select(ph => ph.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
relevantTaskIds = await _context.ProjectTasks
|
||||||
|
.Where(t => projectPhaseIds.Contains(t.PhaseId))
|
||||||
|
.Select(t => t.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectHierarchyLevel.Phase:
|
||||||
|
// برای فاز، تمام تسکهای آن فاز
|
||||||
|
relevantTaskIds = await _context.ProjectTasks
|
||||||
|
.Where(t => t.PhaseId == project.Id)
|
||||||
|
.Select(t => t.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectHierarchyLevel.Task:
|
||||||
|
// برای تسک، خود آن
|
||||||
|
relevantTaskIds = new List<Guid> { project.Id };
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectSections = sections.Where(x => relevantTaskIds.Contains(x.TaskId)).ToList();
|
||||||
|
project.HasBackend = projectSections.Any(x => x.Skill.Name == "Backend");
|
||||||
|
project.HasFront = projectSections.Any(x => x.Skill.Name == "Frontend");
|
||||||
|
project.HasDesign = projectSections.Any(x => x.Skill.Name == "UI/UX Design");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> CalculateProjectPercentage(Project project, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// گرفتن تمام فازهای پروژه
|
||||||
|
var phases = await _context.ProjectPhases
|
||||||
|
.Where(ph => ph.ProjectId == project.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (!phases.Any())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// محاسبه درصد هر فاز و میانگینگیری
|
||||||
|
var phasePercentages = new List<int>();
|
||||||
|
foreach (var phase in phases)
|
||||||
|
{
|
||||||
|
var phasePercentage = await CalculatePhasePercentage(phase, cancellationToken);
|
||||||
|
phasePercentages.Add(phasePercentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return phasePercentages.Any() ? (int)phasePercentages.Average() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> CalculatePhasePercentage(ProjectPhase phase, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// گرفتن تمام تسکهای فاز
|
||||||
|
var tasks = await _context.ProjectTasks
|
||||||
|
.Where(t => t.PhaseId == phase.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (!tasks.Any())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// محاسبه درصد هر تسک و میانگینگیری
|
||||||
|
var taskPercentages = new List<int>();
|
||||||
|
foreach (var task in tasks)
|
||||||
|
{
|
||||||
|
var taskPercentage = await CalculateTaskPercentage(task, cancellationToken);
|
||||||
|
taskPercentages.Add(taskPercentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return taskPercentages.Any() ? (int)taskPercentages.Average() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> CalculateTaskPercentage(ProjectTask task, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
// گرفتن تمام سکشنهای تسک با activities
|
||||||
|
var sections = await _context.TaskSections
|
||||||
|
.Include(s => s.Activities)
|
||||||
|
.Where(s => s.TaskId == task.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (!sections.Any())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// محاسبه درصد هر سکشن و میانگینگیری
|
||||||
|
var sectionPercentages = new List<int>();
|
||||||
|
foreach (var section in sections)
|
||||||
|
{
|
||||||
|
var sectionPercentage = CalculateSectionPercentage(section);
|
||||||
|
sectionPercentages.Add(sectionPercentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sectionPercentages.Any() ? (int)sectionPercentages.Average() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int CalculateSectionPercentage(TaskSection section)
|
||||||
|
{
|
||||||
|
// محاسبه کل زمان تخمین زده شده (اولیه + اضافی)
|
||||||
|
var totalEstimatedHours = section.FinalEstimatedHours.TotalHours;
|
||||||
|
|
||||||
|
if (totalEstimatedHours <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// محاسبه کل زمان صرف شده از activities
|
||||||
|
var totalSpentHours = section.Activities.Sum(a => a.GetTimeSpent().TotalHours);
|
||||||
|
|
||||||
|
// محاسبه درصد (حداکثر 100%)
|
||||||
|
var percentage = (totalSpentHours / totalEstimatedHours) * 100;
|
||||||
|
return Math.Min((int)Math.Round(percentage), 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
|
|
||||||
|
public class GetProjectsListQueryValidator : AbstractValidator<GetProjectsListQuery>
|
||||||
|
{
|
||||||
|
public GetProjectsListQueryValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.HierarchyLevel)
|
||||||
|
.IsInEnum().WithMessage("سطح ارسال شده معتبر نمیباشد.");
|
||||||
|
|
||||||
|
When(x => x.HierarchyLevel != Domain.ProjectAgg.Enums.ProjectHierarchyLevel.Project, () =>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.ParentId)
|
||||||
|
.NotNull().WithMessage("شناسه والد باید برای سطوح غیر از پروژه ارسال شود.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user