Compare commits

...

85 Commits

Author SHA1 Message Date
83b045c2b1 add employer controller 2025-06-17 14:17:26 +03:30
SamSys
9ca041ac18 add Authorization setting for next - subdomain 2025-06-11 15:32:40 +03:30
SamSys
031fb05f8c Menue Change for Next test 2025-06-08 17:09:09 +03:30
SamSys
4aed0ddd68 API ContractingParty Controller Merged 2025-06-07 17:25:27 +03:30
SamSys
9b455d4a2e Fix Conflict 2025-06-03 21:44:00 +03:30
SamSys
0c0e955800 new-Insurance-Opration Merged 2025-06-03 21:43:19 +03:30
SamSys
c948498307 merged changes 2025-06-03 21:27:14 +03:30
f35aca8e44 add migration 2025-06-02 22:48:59 +03:30
16d45c6dc4 merge from master 2025-06-02 22:21:30 +03:30
45e746b194 merge from team work 2025-06-02 22:20:04 +03:30
e3b6d5f1c9 fix task schedule bug 2025-06-02 16:37:23 +03:30
7c1fe65cf2 add sync employee status with left work method on rollcall employee upload picture 2025-06-02 16:29:03 +03:30
f26fcba165 add permissions for mahan 2025-06-02 15:41:06 +03:30
SamSys
de2a6203df LeavePayAndAbsence merged 2025-06-02 13:34:10 +03:30
SamSys
2208834a0e refactor LeavePayMetotds 2025-06-02 13:33:21 +03:30
de52a0be98 change thumbnails for list 2025-06-01 19:00:57 +03:30
SamSys
5bebec3fde Merge branch 'master' of https://github.com/syntax24/OriginalGozareshgir 2025-06-01 17:50:56 +03:30
SamSys
cad808d73c permission change on menu 2025-06-01 17:50:50 +03:30
abef053f56 Merge branch 'master' of https://github.com/syntax24/OriginalGozareshgir 2025-06-01 17:47:37 +03:30
6469bf5a50 fix createEmployee personnel code bug 2025-06-01 17:43:53 +03:30
SamSys
4fd5ef52ef Permission changed 2025-06-01 16:50:27 +03:30
SamSys
61e2bdaaf5 add permission 2025-06-01 16:42:35 +03:30
8ab22d9948 fix admin monthly overview 2025-06-01 16:40:09 +03:30
SamSys
17b5f5fee5 add new Permission 2025-06-01 16:34:31 +03:30
9e7e4ca655 change create condition for contract 2025-06-01 15:56:49 +03:30
SamSys
100c9367ed editRole 2025-06-01 15:30:02 +03:30
fdb6799c65 change modal left work permission 2025-06-01 15:27:48 +03:30
SamSys
c81da3e787 started 2025-05-31 21:05:01 +03:30
SamSys
d8c0471878 Client CameraAccounts new permission added 2025-05-31 17:40:42 +03:30
MahanCh
8418c2edc4 fix sub account bugs 2025-05-31 13:56:02 +03:30
SamSys
e109a41b90 subAccountRole merged 2025-05-31 00:45:26 +03:30
SamSys
158fc91a67 changes 2025-05-31 00:43:50 +03:30
SamSys
d1fb6e933d Merge branch 'Feature/SubAccount/ChangeRole' of https://github.com/syntax24/OriginalGozareshgir into Feature/SubAccount/ChangeRole 2025-05-31 00:34:43 +03:30
SamSys
0811482370 add selected workshops on editRole subAccount 2025-05-31 00:34:36 +03:30
24982e11d3 add tomam 2025-05-30 23:34:08 +03:30
394d65db31 changes 2025-05-30 23:23:53 +03:30
59deae29c2 add workshopIds to role get details 2025-05-30 23:14:38 +03:30
SamSys
5576ee5c24 api started 2025-05-30 23:04:53 +03:30
SamSys
46833f93da changes 2025-05-30 19:06:21 +03:30
SamSys
8d78ea548a Merge branch 'master' of https://github.com/syntax24/OriginalGozareshgir 2025-05-30 19:06:04 +03:30
SamSys
ffbadc5a96 checkout changes 2025-05-30 19:05:55 +03:30
e889b61d27 test 2025-05-30 18:04:12 +03:30
b492aa39e8 changes 2025-05-30 18:03:47 +03:30
2201ade168 merge from teamwork 2025-05-30 15:45:12 +03:30
SamSys
baeeec183b Color change 2025-05-29 14:55:50 +03:30
SamSys
3142a80b44 completed 2 2025-05-29 05:04:57 +03:30
SamSys
7c2354b386 institutionContract bug 0 fixed add new date coler for expiered 2025-05-29 03:05:52 +03:30
SamSys
175158a3d7 Completed 1 2025-05-29 01:31:28 +03:30
MahanCh
b79abcb175 Merge branch 'master' of https://github.com/syntax24/OriginalGozareshgir 2025-05-28 16:50:37 +03:30
MahanCh
7388fd8a81 change order by for abcents rollcall workflows 2025-05-28 16:50:27 +03:30
SamSys
a9c489b43d change 2025-05-27 21:33:09 +03:30
SamSys
66ada45d29 change metod 2025-05-27 20:44:25 +03:30
MahanCh
04e51fe3b5 Kebab mahdi VIP group 2025-05-27 20:06:06 +03:30
SamSys
e486f20a5a chekcoutRepository GetContractResultToCreateCheckout changes NOT FINISHED 2025-05-27 19:21:49 +03:30
MahanCh
2db6a9695c add access accounts to search 2025-05-27 18:40:42 +03:30
MahanCh
cea68fce49 Merge branch 'master' of https://github.com/syntax24/OriginalGozareshgir 2025-05-27 18:06:36 +03:30
MahanCh
3f2c0c5531 fix subAccount Workshop Personnel Count 2025-05-27 18:06:28 +03:30
SamSys
22f13aea0b metode change 2025-05-27 16:18:39 +03:30
0ec62e5e83 change amo logic 2025-05-27 12:47:19 +03:30
SamSys
86a3a21d5b changes 2025-05-26 21:48:09 +03:30
MahanCh
e02bc9adc5 bug Amo Fixed Part 1502 2025-05-26 21:34:21 +03:30
SamSys
39bc95731e front chang amo 2025-05-26 21:28:51 +03:30
SamSys
759792b44b add new permissions to amo 2025-05-26 21:13:50 +03:30
SamSys
1409d30dfd Amo bug fixed 2025-05-26 20:53:56 +03:30
SamSys
ad9f747027 Amo BackEnd Bug fixed And new fron Feature 2025-05-26 17:42:45 +03:30
SamSys
b021636913 add perrmision to AMO on Menu - AdminEmployee Document front Bug Fixed 2025-05-26 17:40:37 +03:30
MahanCh
3007a87104 fix conflict 2025-05-26 17:32:57 +03:30
MahanCh
d7eb8517f7 change sort 2025-05-26 17:32:02 +03:30
MahanCh
eaaab56421 merge from teamwork 2025-05-26 17:30:14 +03:30
SamSys
7d763715cd merge from daylibug 2025-05-25 22:01:09 +03:30
SamSys
7d1eb780a5 amo merged 2025-05-25 21:56:13 +03:30
SamSys
88a9a62dd3 Add new View model : CreateCheckoutListViewModel 2025-05-25 21:20:26 +03:30
SamSys
6fd9b336a9 From Master 2025-05-25 19:09:38 +03:30
SamSys
44d5225ff3 Static Chekoout Bug Fixed 2025-05-25 19:08:49 +03:30
SamSys
03e4f7e8c1 metod Extend 2025-05-25 18:29:18 +03:30
MahanCh
2c6512faa2 task create modal changes 2025-05-25 18:17:39 +03:30
MahanCh
406212a1f0 fix task 2025-05-25 18:01:41 +03:30
MahanCh
53e93bd410 cahnge salaryAidOrderBy 2025-05-25 17:40:36 +03:30
SamSys
9311d68a91 create change 2025-05-25 15:33:42 +03:30
SamSys
9e91214941 Master changes Transfer to Current 2025-05-25 15:33:23 +03:30
SamSys
3e3eccf0f0 add new metod to rcheckoutRepository 2025-05-24 16:33:02 +03:30
MahanCh
f04749043e start new insurancelist operations 2025-05-21 18:25:09 +03:30
MahanCh
e8a9a674a1 merge from job Item 2025-05-21 15:54:53 +03:30
MahanCh
d8b6b0f5e8 New Operation InsuranceList Started! 2025-05-21 15:53:05 +03:30
SamSys
789b0fbc24 started 2025-05-17 18:18:22 +03:30
176 changed files with 37078 additions and 6635 deletions

View File

@@ -12,65 +12,65 @@ namespace _0_Framework.Application;
public class AuthHelper : IAuthHelper
{
private readonly IHttpContextAccessor _contextAccessor;
public AuthHelper(IHttpContextAccessor contextAccessor)
{
_contextAccessor = contextAccessor;
}
private readonly IHttpContextAccessor _contextAccessor;
public AuthViewModel CurrentAccountInfo()
{
var result = new AuthViewModel();
if (!IsAuthenticated())
return result;
public AuthHelper(IHttpContextAccessor contextAccessor)
{
_contextAccessor = contextAccessor;
}
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.ProfilePhoto = claims.FirstOrDefault(x => x.Type == "ProfilePhoto")?.Value;
result.RoleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value);
result.Fullname = claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
result.Role = claims.FirstOrDefault(x => x.Type == "RoleName")?.Value;
result.ClientAriaPermission =claims.FirstOrDefault(x => x.Type == "ClientAriaPermission").Value;
result.AdminAreaPermission = claims.FirstOrDefault(x => x.Type == "AdminAreaPermission").Value;
result.PositionValue = !string.IsNullOrWhiteSpace(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) ? int.Parse(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) : 0;
result.WorkshopList = Tools.DeserializeFromBsonList<WorkshopClaim>(claims.FirstOrDefault(x => x is { Type: "workshopList" })?.Value);
result.WorkshopSlug = claims.FirstOrDefault(x => x is { Type: "WorkshopSlug" }).Value;
result.Mobile = claims.FirstOrDefault(x => x is { Type: "Mobile" }).Value;
public AuthViewModel CurrentAccountInfo()
{
var result = new AuthViewModel();
if (!IsAuthenticated())
return result;
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.ProfilePhoto = claims.FirstOrDefault(x => x.Type == "ProfilePhoto")?.Value;
result.RoleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value);
result.Fullname = claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
result.Role = claims.FirstOrDefault(x => x.Type == "RoleName")?.Value;
result.ClientAriaPermission = claims.FirstOrDefault(x => x.Type == "ClientAriaPermission").Value;
result.AdminAreaPermission = claims.FirstOrDefault(x => x.Type == "AdminAreaPermission").Value;
result.PositionValue = !string.IsNullOrWhiteSpace(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) ? int.Parse(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) : 0;
result.WorkshopList = Tools.DeserializeFromBsonList<WorkshopClaim>(claims.FirstOrDefault(x => x is { Type: "workshopList" })?.Value);
result.WorkshopSlug = claims.FirstOrDefault(x => x is { Type: "WorkshopSlug" }).Value;
result.Mobile = claims.FirstOrDefault(x => x is { Type: "Mobile" }).Value;
result.SubAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId").Value);
result.WorkshopName = claims.FirstOrDefault(x => x is { Type: "WorkshopName" })?.Value;
return result;
}
}
public List<int> GetPermissions()
{
if (!IsAuthenticated())
return new List<int>();
public List<int> GetPermissions()
{
if (!IsAuthenticated())
return new List<int>();
var permissions = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "permissions")
?.Value;
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
}
var permissions = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "permissions")
?.Value;
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
}
public long CurrentAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value)
: 0;
}
public long CurrentSubAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "SubAccountId")?.Value)
: 0;
}
public long CurrentAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value)
: 0;
}
public long CurrentSubAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "SubAccountId")?.Value)
: 0;
}
public string CurrentAccountMobile()
{
return IsAuthenticated()
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "Mobile")?.Value
: "";
}
{
return IsAuthenticated()
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "Mobile")?.Value
: "";
}
#region Vafa
@@ -111,160 +111,166 @@ public class AuthHelper : IAuthHelper
}
public string GetWorkshopSlug()
{
return CurrentAccountInfo().ClientAriaPermission == "true"
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value
: "";
}
public string GetWorkshopName()
{
var workshopName = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "ClientAriaPermission")?.Value == "true";
if (workshopName)
{
return _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopName")?.Value;
}
{
return CurrentAccountInfo().ClientAriaPermission == "true"
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value
: "";
}
public string GetWorkshopName()
{
var workshopName = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "ClientAriaPermission")?.Value == "true";
if (workshopName)
{
return _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopName")?.Value;
}
return "";
}
return "";
}
#endregion
public string CurrentAccountRole()
{
if (IsAuthenticated())
return _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
return null;
}
{
if (IsAuthenticated())
return _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
return null;
}
public bool IsAuthenticated()
{
return _contextAccessor.HttpContext.User.Identity.IsAuthenticated;
//var claims = _contextAccessor.HttpContext.User.Claims.ToList();
//if (claims.Count > 0)
// return true;
//return false;
//return claims.Count > 0;
}
public bool IsAuthenticated()
{
return _contextAccessor.HttpContext.User.Identity.IsAuthenticated;
//var claims = _contextAccessor.HttpContext.User.Claims.ToList();
//if (claims.Count > 0)
// return true;
//return false;
//return claims.Count > 0;
}
public void Signin(AuthViewModel account)
{
#region MahanChanges
public void Signin(AuthViewModel account)
{
#region MahanChanges
var permissions = account.Permissions is { Count: > 0 } ? Tools.SerializeToBson(account.Permissions) : "";
var workshopBson = account.WorkshopList is { Count: > 0 } ? Tools.SerializeToBson(account.WorkshopList) : "";
var slug = account.WorkshopSlug ?? "";
if (account.Id == 322)
account.Permissions.AddRange([3060301, 30603, 30604, 30605]);
#endregion
var permissions = account.Permissions is { Count: > 0 } ? Tools.SerializeToBson(account.Permissions) : "";
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim(ClaimTypes.Name, account.Fullname),
new Claim(ClaimTypes.Role, account.RoleId.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
var workshopBson = account.WorkshopList is { Count: > 0 } ? Tools.SerializeToBson(account.WorkshopList) : "";
var slug = account.WorkshopSlug ?? "";
#endregion
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim(ClaimTypes.Name, account.Fullname),
new Claim(ClaimTypes.Role, account.RoleId.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
new Claim("permissions", permissions),
new Claim("Mobile", account.Mobile),
new Claim("ProfilePhoto", account.ProfilePhoto ),
new Claim("RoleName", account.RoleName),
new Claim("SubAccountId", account.SubAccountId.ToString()),
new Claim("Mobile", account.Mobile),
new Claim("ProfilePhoto", account.ProfilePhoto ),
new Claim("RoleName", account.RoleName),
new Claim("SubAccountId", account.SubAccountId.ToString()),
new Claim("AdminAreaPermission", account.AdminAreaPermission.ToString()),
new Claim("ClientAriaPermission", account.ClientAriaPermission.ToString()),
new Claim("IsCamera", "false"),
new Claim("PositionValue",account.PositionValue.ToString()),
new Claim("ClientAriaPermission", account.ClientAriaPermission.ToString()),
new Claim("IsCamera", "false"),
new Claim("PositionValue",account.PositionValue.ToString()),
//mahanChanges
new("workshopList",workshopBson),
new("WorkshopSlug",slug),
new("WorkshopName",account.WorkshopName??"")
new("WorkshopSlug",slug),
new("WorkshopName",account.WorkshopName??"")
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
#region Camera
public void CameraSignIn(CameraAuthViewModel account)
{
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
#region Camera
public void CameraSignIn(CameraAuthViewModel account)
{
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
new Claim("WorkshopId", account.WorkshopId.ToString()),
new Claim("WorkshopName", account.WorkshopName),
new Claim("Mobile", account.Mobile),
new Claim("AccountId", account.AccountId.ToString()),
new Claim("IsActiveString", account.IsActiveString),
new Claim("IsCamera", "true"),
new Claim("WorkshopName", account.WorkshopName),
new Claim("Mobile", account.Mobile),
new Claim("AccountId", account.AccountId.ToString()),
new Claim("IsActiveString", account.IsActiveString),
new Claim("IsCamera", "true"),
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties
{
var authProperties = new AuthenticationProperties
{
//ExpiresUtc = DateTimeOffset.UtcNow.AddDays(30)
ExpiresUtc = new DateTimeOffset(year: 2100, month: 1, day: 1, hour: 0, minute: 0, second: 0, offset: TimeSpan.Zero)
};
//ExpiresUtc = DateTimeOffset.UtcNow.AddDays(30)
ExpiresUtc = new DateTimeOffset(year: 2100, month: 1, day: 1, hour: 0, minute: 0, second: 0, offset: TimeSpan.Zero)
};
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
public CameraAuthViewModel CameraAccountInfo()
{
var result = new CameraAuthViewModel();
if (!IsAuthenticated())
return result;
public CameraAuthViewModel CameraAccountInfo()
{
var result = new CameraAuthViewModel();
if (!IsAuthenticated())
return result;
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.WorkshopId = long.Parse(claims.FirstOrDefault(x => x.Type == "WorkshopId")?.Value);
result.WorkshopName = claims.FirstOrDefault(x => x.Type == "WorkshopName").Value;
result.Mobile = claims.FirstOrDefault(x => x.Type == "Mobile").Value;
result.AccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId")?.Value);
result.IsActiveString = claims.FirstOrDefault(x => x.Type == "IsActiveString").Value;
return result;
}
#endregion
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.WorkshopId = long.Parse(claims.FirstOrDefault(x => x.Type == "WorkshopId")?.Value);
result.WorkshopName = claims.FirstOrDefault(x => x.Type == "WorkshopName").Value;
result.Mobile = claims.FirstOrDefault(x => x.Type == "Mobile").Value;
result.AccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId")?.Value);
result.IsActiveString = claims.FirstOrDefault(x => x.Type == "IsActiveString").Value;
return result;
}
#endregion
public void SignOut()
{
_contextAccessor.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
public void SignOut()
{
_contextAccessor.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
#region Pooya
#region Pooya
public (long Id, UserType userType, long roleId) GetUserTypeWithId()
{
if (!IsAuthenticated())
return (0, UserType.Anonymous, 0);
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
public (long Id, UserType userType, long roleId) GetUserTypeWithId()
{
if (!IsAuthenticated())
return (0, UserType.Anonymous, 0);
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
var subAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId")?.Value ?? "0");
if (subAccountId > 0)
return (subAccountId, UserType.SubAccount, 0);
var subAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId")?.Value ?? "0");
if (subAccountId > 0)
return (subAccountId, UserType.SubAccount, 0);
var id = long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value);
if (claims.FirstOrDefault(x => x.Type == "AdminAreaPermission")?.Value == "true")
{
var roleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "0");
return (id, UserType.Admin, roleId);
}
var id = long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value);
if (claims.FirstOrDefault(x => x.Type == "AdminAreaPermission")?.Value == "true")
{
var roleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "0");
return (id, UserType.Admin, roleId);
}
return (id, UserType.Client, 0);
}
#endregion
return (id, UserType.Client, 0);
}
#endregion
}

View File

@@ -0,0 +1,8 @@
namespace _0_Framework.Application.Enums;
public enum ActivationStatus
{
None = 0,
Active = 1,
DeActive = 2
}

View File

@@ -0,0 +1,8 @@
namespace _0_Framework.Application.Enums;
public enum LegalType
{
None = 0,
Real = 1,
Legal = 2
}

View File

@@ -0,0 +1,7 @@
namespace _0_Framework.Application;
public class SelectListViewModel
{
public long Id { get; set; }
public string Text { get; set; }
}

View File

@@ -385,11 +385,27 @@
/// </summary>
public const int SetWorkshopWorkingHoursPermissionCode = 10606;
#region حساب کاربری دوربین
/// <summary>
/// تنظیمات حساب کاربری دوربین
/// </summary>
public const int CameraAccountSettingsPermissionCode = 10607;
/// <summary>
/// فعال/غیرفعال اکانت دوربین
/// </summary>
public const int CameraAccountActivationBtnPermissionCode = 1060701;
/// <summary>
/// ویرایش اکانت دوربین
/// </summary>
public const int CameraAccountEditPermissionCode = 1060702;
#endregion
#endregion
#region کارپوشه
@@ -744,6 +760,22 @@
Code = CameraAccountSettingsPermissionCode,
ParentId = RollCallOperationsPermissionCode
};
public static SubAccountPermissionDto CameraAccountActivationBtn { get; } = new()
{
Id = CameraAccountActivationBtnPermissionCode,
Name = "فعال/غیرفعال حساب کاربری دوربین",
Code = CameraAccountActivationBtnPermissionCode,
ParentId = CameraAccountSettingsPermissionCode
};
public static SubAccountPermissionDto CameraAccountEdit { get; } = new()
{
Id = CameraAccountEditPermissionCode,
Name = "ویراش حساب کاربری دوربین",
Code = CameraAccountEditPermissionCode,
ParentId = CameraAccountSettingsPermissionCode
};
#endregion
#region کارپوشه,ParentId = WorkFlowOperationsPermissionCode

View File

@@ -4,4 +4,6 @@ public class AccountSelectListViewModel
{
public long Id { get; set; }
public string Name { get; set; }
public long RoleId { get; set; }
}

View File

@@ -4,12 +4,13 @@ using System.Collections.Generic;
namespace AccountManagement.Application.Contracts.Media
{
public interface IMediaApplication
{
MediaViewModel Get(long id);
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength, List<string> allowedExtensions);
OperationResult MoveFile(long mediaId, string newRelativePath);
OperationResult DeleteFile(long mediaId);
List<MediaViewModel> GetRange(IEnumerable<long> select);
}
}
public interface IMediaApplication
{
MediaViewModel Get(long id);
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
List<string> allowedExtensions, string category);
OperationResult MoveFile(long mediaId, string newRelativePath);
OperationResult DeleteFile(long mediaId);
List<MediaViewModel> GetRange(IEnumerable<long> select);
}
}

View File

@@ -15,6 +15,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
public string PhoneNumber { get; set; }
public string Username { get; set; }
public string ProfilePhoto { get; set; }
public List<long> WorkshopIds { get; set; }
//public List<long> WorkshopIds { get; set; }
}
}

View File

@@ -8,5 +8,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
public string Title { get; set; }
public long AccountId { get; set; }
public List<int> Permissions { get; set; }
public List<long> WorkshopIds { get; set; }
}
}

View File

@@ -13,7 +13,7 @@ namespace AccountManagement.Application.Contracts.SubAccount
public string PhoneNumber { get; set; }
public string RePassword { get; set; }
public long SubAccountRoleId { get; set; }
public List<long> WorkshopIds { get; set; }
//public List<long> WorkshopIds { get; set; }
}

View File

@@ -7,5 +7,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
public long Id { get; set; }
public string Title { get; set; }
public List<int> Permissions { get; set; }
public List<long> WorkshopIds { get; set; }
}
}

View File

@@ -308,7 +308,7 @@ public class AccountApplication : IAccountApplication
{
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
Name = x.WorkshopName,
PersonnelCount = 0,
PersonnelCount = x.PersonnelCount,
Id = x.WorkshopId
}).ToList();

View File

@@ -9,147 +9,113 @@ using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application
{
public class MediaApplication:IMediaApplication
{
public class MediaApplication : IMediaApplication
{
private const string _basePath = "Medias";
private readonly IMediaRepository _mediaRepository;
private const string _basePath = "Medias";
private readonly IMediaRepository _mediaRepository;
public MediaApplication(IMediaRepository mediaRepository)
{
_mediaRepository = mediaRepository;
}
public MediaApplication(IMediaRepository mediaRepository)
{
_mediaRepository = mediaRepository;
}
/// <summary>
/// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا
/// </summary>
/// <param name="file">فایل</param>
/// <param name="fileLabel">برچسب فایل که در نام فایل ظاهر می شود</param>
/// <param name="relativePath">مسیر فایل</param>
/// <param name="allowedExtensions">[.png,.jpg,.jpeg] پسوند های مجاز مثلا </param>
/// <param name="maximumFileLength">حداکثر حجم فایل به مگابایت</param>
/// <returns></returns>
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath,int maximumFileLength,List<string> allowedExtensions)
{
OperationResult op = new();
var path = Path.Combine(_basePath, relativePath);
var fileExtension = Path.GetExtension(file.FileName);
if (file == null || file.Length == 0)
return op.Failed("خطای سیستمی");
if (file.Length > (maximumFileLength * 1024 * 1024))
return op.Failed($"حجم فایل نمی تواند بیشتر از " +
$"{maximumFileLength}" +
$"مگابایت باشد");
if (!allowedExtensions.Contains(fileExtension.ToLower()))
{
var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد";
operationMessage += "\n";
operationMessage += string.Join(" ", allowedExtensions);
return op.Failed(operationMessage);
}
/// <summary>
/// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا
/// </summary>
/// <param name="file">فایل</param>
/// <param name="fileLabel">برچسب فایل که در نام فایل ظاهر می شود</param>
/// <param name="relativePath">مسیر فایل</param>
/// <param name="maximumFileLength">حداکثر حجم فایل به مگابایت</param>
/// <param name="allowedExtensions">[.png,.jpg,.jpeg] پسوند های مجاز مثلا </param>
/// <param name="category"></param>
/// <returns></returns>
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
List<string> allowedExtensions, string category)
{
return _mediaRepository.UploadFile(file, fileLabel, relativePath, maximumFileLength, allowedExtensions, category);
}
Directory.CreateDirectory(path);
/// <summary>
/// حذف فایل
/// </summary>
public OperationResult DeleteFile(long mediaId)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
if (media == null)
return op.Failed("رکورد مورد نظر یافت نشد");
try
{
if (File.Exists(media.Path))
File.Delete(media.Path);
else
return op.Failed("فایل یافت نشد");
}
catch
{
return op.Failed("خطایی در حذف فایل رخ داده است");
}
var extension = Path.GetExtension(file.FileName);
_mediaRepository.Remove(media.id);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
var uniqueFileName = $"{fileLabel}-{DateTime.Now.Ticks}{extension}";
var filePath = Path.Combine(path, uniqueFileName);
using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
{
file.CopyTo(fileStream);
}
var mediaEntity = new Media(filePath, extension, "فایل", "EmployeeDocuments");
_mediaRepository.Create(mediaEntity);
_mediaRepository.SaveChanges();
/// <summary>
/// جابجا کردن فایل
/// </summary>
public OperationResult MoveFile(long mediaId, string newRelativePath)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
var oldPath = media.Path;
var path = Path.Combine(_basePath, newRelativePath);
Directory.CreateDirectory(path);
return op.Succcedded(mediaEntity.id);
string filepath = Path.Combine(path, Path.GetFileName(oldPath));
try
{
File.Move(oldPath, filepath);
}
catch
{
return op.Failed("در جابجایی فایل خطایی رخ داده است");
}
}
media.Edit(filepath, media.Type, media.Category);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
public MediaViewModel Get(long id)
{
var media = _mediaRepository.Get(id);
if (media == null)
return new();
return new MediaViewModel()
{
Category = media.Category,
Path = media.Path,
Id = media.id,
Type = media.Type
};
}
/// <summary>
/// حذف فایل
/// </summary>
public OperationResult DeleteFile(long mediaId)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
if (media == null)
return op.Failed("رکورد مورد نظر یافت نشد");
try
{
if (File.Exists(media.Path))
File.Delete(media.Path);
else
return op.Failed("فایل یافت نشد");
}
catch
{
return op.Failed("خطایی در حذف فایل رخ داده است");
}
public List<MediaViewModel> GetRange(IEnumerable<long> ids)
{
var medias = _mediaRepository.GetRange(ids);
return medias.Select(x => new MediaViewModel()
{
Category = x.Category,
Path = x.Path,
Id = x.id,
Type = x.Type,
}).ToList();
}
_mediaRepository.Remove(media.id);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
/// <summary>
/// جابجا کردن فایل
/// </summary>
public OperationResult MoveFile(long mediaId, string newRelativePath)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
var oldPath = media.Path;
var path = Path.Combine(_basePath, newRelativePath);
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, Path.GetFileName(oldPath));
try
{
File.Move(oldPath, filepath);
}
catch
{
return op.Failed("در جابجایی فایل خطایی رخ داده است");
}
media.Edit(filepath, media.Type, media.Category);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
public MediaViewModel Get(long id)
{
var media = _mediaRepository.Get(id);
if (media == null)
return new();
return new MediaViewModel()
{
Category = media.Category,
Path = media.Path,
Id = media.id,
Type = media.Type
};
}
public List<MediaViewModel> GetRange(IEnumerable<long> ids)
{
var medias = _mediaRepository.GetRange(ids);
return medias.Select(x=>new MediaViewModel()
{
Category = x.Category,
Path = x.Path,
Id = x.id,
Type = x.Type,
}).ToList();
}
}
}
}

View File

@@ -113,12 +113,12 @@ namespace AccountManagement.Application
if (cmd.PhoneNumber.Length != 11)
return op.Failed("شماره تلفن همراه نامعتبر است");
if (!cmd.WorkshopIds.Any())
return op.Failed("حداقل یک کارگاه را انتخاب کنید");
//if (!cmd.WorkshopIds.Any())
// return op.Failed("حداقل یک کارگاه را انتخاب کنید");
if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
return op.Failed("خطای سیستمی");
//if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
// return op.Failed("خطای سیستمی");
if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id))
@@ -131,6 +131,10 @@ namespace AccountManagement.Application
_cameraAccountRepository.Exists(x => x.Username == cmd.Username))
return op.Failed("نام کاربری نمی تواند تکراری باشد");
var role = _subAccountRoleRepository.Get(cmd.SubAccountRoleId);
var workshopId = role.RoleWorkshops.Select(x => x.WorkshopId).ToList();
var entity = new SubAccount(cmd.AccountId, cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.PhoneNumber, cmd.Username, _passwordHasher.Hash(cmd.Password),
cmd.ProfilePhoto);
@@ -142,7 +146,7 @@ namespace AccountManagement.Application
_subAccountRepository.SaveChanges();
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
var workshops = workshopId.Select(x => new WorkshopSubAccount(x, entity.id));
foreach (var w in workshops)
_workshopSubAccountRepository.Create(w);
@@ -175,22 +179,22 @@ namespace AccountManagement.Application
if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
return op.Failed("خطای سیستمی");
//if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
// return op.Failed("خطای سیستمی");
if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id))
return op.Failed("نقش مورد نظر وجود ندارد");
var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id);
foreach (var workshopSubAccount in workshopSubAccounts)
_workshopSubAccountRepository.Remove(workshopSubAccount);
//var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id);
//foreach (var workshopSubAccount in workshopSubAccounts)
// _workshopSubAccountRepository.Remove(workshopSubAccount);
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
//var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
foreach (var w in workshops)
_workshopSubAccountRepository.Create(w);
//foreach (var w in workshops)
// _workshopSubAccountRepository.Create(w);
entity.Edit(cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.ProfilePhoto);
_workshopSubAccountRepository.SaveChanges();
@@ -227,7 +231,8 @@ namespace AccountManagement.Application
{
Id = entity.id,
Title = entity.Title,
Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList()
Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList(),
WorkshopIds = entity.RoleWorkshops.Select(x=>x.WorkshopId).ToList()
};
}
@@ -241,7 +246,7 @@ namespace AccountManagement.Application
OperationResult op = new();
if (_subAccountRoleRepository.Exists(x => x.AccountId == command.AccountId && x.Title.Trim() == command.Title.Trim()))
return op.Failed("یک نقش با این عنوان وجود دارد");
var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId);
var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId,command.WorkshopIds);
_subAccountRoleRepository.Create(role);
_subAccountRoleRepository.SaveChanges();
return op.Succcedded(role.id);
@@ -254,8 +259,26 @@ namespace AccountManagement.Application
var entity = _subAccountRoleRepository.Get(cmd.Id);
if (entity == null)
return op.Failed(ApplicationMessages.RecordNotFound);
entity.Edit(cmd.Title, cmd.Permissions);
_subAccountRoleRepository.SaveChanges();
entity.Edit(cmd.Title, cmd.Permissions,cmd.WorkshopIds);
var subAccountRoles = _subAccountRepository.GetBySubAccountRole(cmd.Id);
foreach (var subAccount in subAccountRoles)
{
var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(subAccount.id);
foreach (var workshopSubAccount in workshopSubAccounts)
_workshopSubAccountRepository.Remove(workshopSubAccount);
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, subAccount.id));
foreach (var w in workshops)
_workshopSubAccountRepository.Create(w);
}
_subAccountRoleRepository.SaveChanges();
_workshopSubAccountRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult AssignRoleToSubAccount(AssignSubAccountRole command)

View File

@@ -597,7 +597,7 @@ public class TaskApplication : ITaskApplication
}
assign.AcceptTimeRequest();
message = string.IsNullOrWhiteSpace(message) ? "درخواست شما مورد تایید قرار گرفت" : message;
var messageEntity = new TaskMessage(message, "تایید درخواست مهلت", assign.id);
@@ -622,6 +622,7 @@ public class TaskApplication : ITaskApplication
{
return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
}
assign.RejectTimeRequest();
if (assign.EndTaskDate.Date <= DateTime.Now.Date)
{

View File

@@ -71,14 +71,16 @@ public class Assign : EntityBase
public void AcceptTimeRequest()
{
TimeRequest = false;
ClearRequests();
TimeRequest = false;
AcceptedTimeRequest++;
EndTaskDate = RequestDate < DateTime.Today ? DateTime.Today : RequestDate.Value;
}
public void RejectTimeRequest()
{
TimeRequest = false;
ClearRequests();
TimeRequest = false;
TimeRequestDescription = null;
RequestDate = null;
}
@@ -92,31 +94,36 @@ public class Assign : EntityBase
}
public void AcceptCancelRequest()
{
IsCanceledRequest = false;
ClearRequests();
IsCanceledRequest = false;
IsCancel = true;
}
public void RejectCancel()
{
CancelDescription = null;
ClearRequests();
CancelDescription = null;
IsCanceledRequest = false;
}
public void CompleteRequest(string? doneDescription)
{
DoneDescription = doneDescription;
ClearRequests();
DoneDescription = doneDescription;
IsDoneRequest = true;
}
public void RejectCompleteRequest()
{
IsDoneRequest = false;
ClearRequests();
IsDoneRequest = false;
DoneDescription = null;
}
public void Completed()
{
IsDoneRequest = false;
ClearRequests();
IsDoneRequest = false;
IsDone = true;
}
@@ -128,6 +135,13 @@ public class Assign : EntityBase
TimeRequest = false;
}
public void ClearRequests()
{
IsDoneRequest = false;
IsCanceledRequest = false;
TimeRequest = false;
}
public void InsertNewData(DateTime endTaskDate,bool timeRequest,int acceptedTimeRequest,DateTime? requestDate, string timeRequestDescription, bool isCanceledRequest,
bool isCancel,string cancelDescription,bool isDone,bool isDoneRequest,string? doneDescription)
{

View File

@@ -1,12 +1,15 @@
using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.Domain;
using AccountManagement.Application.Contracts.Media;
using Microsoft.AspNetCore.Http;
namespace AccountManagement.Domain.MediaAgg;
public interface IMediaRepository:IRepository<long,Media>
public interface IMediaRepository : IRepository<long, Media>
{
public string BasePath { get; protected set; }
void CreateMediaWithTaskMedia(long taskId, long mediaId);
List<MediaViewModel> GetMediaByTaskId(long taskId);
void Remove(long id);
@@ -23,4 +26,6 @@ public interface IMediaRepository:IRepository<long,Media>
#endregion
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
List<string> allowedExtensions, string category);
}

View File

@@ -2,6 +2,7 @@
using _0_Framework.Domain;
using AccountManagement.Application.Contracts.SubAccount;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace AccountManagement.Domain.SubAccountAgg
{
@@ -13,5 +14,6 @@ namespace AccountManagement.Domain.SubAccountAgg
SubAccount GetDetails(long subAccountId);
SubAccount GetBy(string commandUsername);
SubAccountViewModel GetByVerifyCodeAndPhoneNumber(string code, string phone);
List<SubAccount> GetBySubAccountRole(long subAccountRoleId);
}
}

View File

@@ -13,17 +13,21 @@ namespace AccountManagement.Domain.SubAccountRoleAgg
public List<SubAccountRolePermission> RolePermissions { get; private set; }
public List<SubAccount> SubAccounts { get; private set; }
public List<SubAccountRoleWorkshop> RoleWorkshops { get; set; }
private SubAccountRole()
{
}
public SubAccountRole(string title, List<int> permissions, long accountId)
public SubAccountRole(string title, List<int> permissions, long accountId, List<long> workshopIds)
{
Title = title;
RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList();
AccountId = accountId;
RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList();
}
public void ChangeTitle(string title)
{
Title = title;
@@ -32,10 +36,12 @@ namespace AccountManagement.Domain.SubAccountRoleAgg
{
RolePermissions.AddRange(permissionIds.Select(x => new SubAccountRolePermission(x, id)));
}
public void Edit(string title, List<int> permissions)
public void Edit(string title, List<int> permissions,List<long> workshopIds)
{
Title = title;
RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList();
}
}
RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList();
}
}
}

View File

@@ -0,0 +1,16 @@
using _0_Framework.Domain;
namespace AccountManagement.Domain.SubAccountRoleAgg;
public class SubAccountRoleWorkshop:EntityBase
{
public SubAccountRoleWorkshop(long workshopId, long subAccountId)
{
WorkshopId = workshopId;
SubAccountId = subAccountId;
}
public long WorkshopId { get; set; }
public long SubAccountId { get; set; }
public SubAccountRole SubAccountRole { get; set; }
}

View File

@@ -16,7 +16,7 @@ public class TaskSchedule:EntityBase
UnitType = unitType;
UnitNumber = unitNumber;
LastEndTaskDate = lastEndTaskDate;
IsActive = IsActive.False;
IsActive = IsActive.True;
}
public string Count { get; private set; }
public TaskScheduleType Type { get; private set; }

View File

@@ -21,6 +21,10 @@ namespace AccountMangement.Infrastructure.EFCore.Mappings
opt.WithOwner(x => x.SubAccountRole);
});
builder.OwnsMany(x => x.RoleWorkshops, roleWorkshop =>
{
roleWorkshop.WithOwner(x => x.SubAccountRole).HasForeignKey(x => x.SubAccountId);
});
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AccountMangement.Infrastructure.EFCore.Migrations
{
/// <inheritdoc />
public partial class addworkshoptosubAccountRole : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SubAccountRoleWorkshop",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SubAccountId = table.Column<long>(type: "bigint", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SubAccountRoleWorkshop", x => new { x.SubAccountId, x.id });
table.ForeignKey(
name: "FK_SubAccountRoleWorkshop_SubAccountRoles_SubAccountId",
column: x => x.SubAccountId,
principalTable: "SubAccountRoles",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SubAccountRoleWorkshop");
}
}
}

View File

@@ -1078,6 +1078,33 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b =>
{
b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRoleWorkshop", "RoleWorkshops", b1 =>
{
b1.Property<long>("SubAccountId")
.HasColumnType("bigint");
b1.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("id"));
b1.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b1.Property<long>("WorkshopId")
.HasColumnType("bigint");
b1.HasKey("SubAccountId", "id");
b1.ToTable("SubAccountRoleWorkshop");
b1.WithOwner("SubAccountRole")
.HasForeignKey("SubAccountId");
b1.Navigation("SubAccountRole");
});
b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRolePermission", "RolePermissions", b1 =>
{
b1.Property<long>("id")
@@ -1105,6 +1132,8 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
});
b.Navigation("RolePermissions");
b.Navigation("RoleWorkshops");
});
modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b =>

View File

@@ -318,7 +318,8 @@ public class AccountRepository : RepositoryBase<long, Account>, IAccountReposito
return await _context.Accounts.Where(x => x.AdminAreaPermission == "true").Select(x => new AccountSelectListViewModel()
{
Id = x.id,
Name = x.Fullname
Name = x.Fullname,
RoleId = x.RoleId
}).ToListAsync();
}

View File

@@ -1,5 +1,8 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.Media;
using AccountManagement.Domain.AdminResponseMediaAgg;
@@ -7,27 +10,35 @@ using AccountManagement.Domain.ClientResponseMediaAgg;
using AccountManagement.Domain.MediaAgg;
using AccountManagement.Domain.TaskMediaAgg;
using AccountManagement.Domain.TicketMediasAgg;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
namespace AccountMangement.Infrastructure.EFCore.Repository;
public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
public class MediaRepository : RepositoryBase<long, Media>, IMediaRepository
{
private const string _basePath = "Storage/Medias";
public string BasePath { get; set; }
private readonly AccountContext _accountContext;
public MediaRepository( AccountContext taskManagerContext) : base(taskManagerContext)
public MediaRepository(AccountContext taskManagerContext, IWebHostEnvironment webHostEnvironment) : base(taskManagerContext)
{
_accountContext = taskManagerContext;
BasePath = webHostEnvironment.ContentRootPath + "/Storage";
}
//ساخت جدول واسط بین مدیا و نسک
//نکته: این متد ذخیره انجام نمیدهد
public void CreateMediaWithTaskMedia(long taskId, long mediaId)
{
var Taskmedias = new TaskMedia(taskId,mediaId);
var Taskmedias = new TaskMedia(taskId, mediaId);
_accountContext.Add(Taskmedias);
}
public void Remove(long id)
{
var media = Get(id);
var media = Get(id);
Remove(media);
}
@@ -77,6 +88,48 @@ public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
{
return _accountContext.Medias.Where(x => mediaIds.Contains(x.id)).ToList();
}
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
List<string> allowedExtensions, string category)
{
OperationResult op = new();
var path = Path.Combine(_basePath, relativePath);
var fileExtension = Path.GetExtension(file.FileName);
if (file == null || file.Length == 0)
return op.Failed("خطای سیستمی");
if (file.Length > (maximumFileLength * 1024 * 1024))
return op.Failed($"حجم فایل نمی تواند بیشتر از " +
$"{maximumFileLength}" +
$"مگابایت باشد");
if (!allowedExtensions.Contains(fileExtension.ToLower()))
{
var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد";
operationMessage += "\n";
operationMessage += string.Join(" ", allowedExtensions);
return op.Failed(operationMessage);
}
Directory.CreateDirectory(path);
var extension = Path.GetExtension(file.FileName);
var uniqueFileName = $"{fileLabel}-{DateTime.Now.Ticks}{extension}";
var filePath = Path.Combine(path, uniqueFileName);
using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
{
file.CopyTo(fileStream);
}
var mediaEntity = new Media(filePath, extension, "فایل", category);
Create(mediaEntity);
SaveChanges();
return op.Succcedded(mediaEntity.id);
}
}
#endregion

View File

@@ -77,5 +77,10 @@ namespace AccountMangement.Infrastructure.EFCore.Repository
Username = entity.Username
};
}
public List<SubAccount> GetBySubAccountRole(long subAccountRoleId)
{
return _context.SubAccounts.Where(x => x.SubAccountRoleId == subAccountRoleId).ToList();
}
}
}

View File

@@ -900,7 +900,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
AcceptedTimeRequest = x.AcceptedTimeRequest,
IsCancelRequest = x.IsCancelRequest,
ContractingPartyName = x.ContractingPartyName,
Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel, false),
Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel,false),
MediaCount = x.MediaCount,
HasAttachment = x.MediaCount > 0,
SelfName = x.SelfName,
@@ -1866,7 +1866,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
.Include(x => x.Task).ThenInclude(x => x.TaskSchedule)
.Where(x =>
x.Task.IsActiveString == "true" && x.Task.SenderId == accountId
&& x.Task.TaskScheduleId != null && x.Task.TaskScheduleId > 0 && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest) && x.Task.TaskSchedule.IsActive == IsActive.True);
&& x.Task.TaskScheduleId != null && x.Task.TaskScheduleId > 0 && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest) && x.Task.TaskSchedule.IsActive== IsActive.True);
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
{
raw = raw.Where(x =>
@@ -2153,7 +2153,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
return final;
}
public string SetTasksColors(DateTime date, bool isCancel, bool hasRequest)
public string SetTasksColors(DateTime date, bool isCancel,bool hasRequest)
{
if (hasRequest)
return "red";
@@ -2735,7 +2735,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
var raw = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias)
.ThenInclude(x => x.Media)
.Where(x =>
x.Task.IsActiveString == "true" && x.AssignedId == accountId && x.Task.TicketId == null);
x.Task.IsActiveString == "true" && x.AssignedId == accountId && x.Task.TicketId == null &&!x.IsDoneRequest && !x.IsCanceledRequest);
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
{
raw = raw.Where(x =>
@@ -2768,7 +2768,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id),
Description = x.Task.Description,
IsDoneRequest = x.IsDoneRequest,
});
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
{
@@ -2878,8 +2878,8 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
var orderResult = result.OrderBy(x => x.IsDone || x.IsCancel)
.ThenByDescending(x => x.EndTaskDateGE <= today.AddDays(1) && !x.HasRequest)
.ThenByDescending(x => x.HasRequest)
.ThenByDescending(x => x.EndTaskDateGE <= today.AddDays(1) && !x.RequestTime)
.ThenByDescending(x => x.RequestTime)
.ThenBy(x => x.EndTaskDateGE); // مرتب‌سازی داخلی بر اساس تاریخ
@@ -2915,7 +2915,6 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
SelfName = x.SelfName,
Description = x.Description,
IsDoneRequest = x.IsDoneRequest,
HasRequest = x.IsDoneRequest || x.RequestTime || x.IsCancelRequest
}).ToList();
@@ -2943,7 +2942,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
AcceptedTimeRequest = x.AcceptedTimeRequest,
IsCancelRequest = x.IsCancelRequest,
ContractingPartyName = x.ContractingPartyName,
Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel, x.HasRequest),
Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel,x.RequestTime),
MediaCount = x.MediaCount,
HasAttachment = x.MediaCount > 0,
SelfName = x.SelfName,
@@ -3003,6 +3002,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
AssignedPositionValue = 0
},
HasRequest = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest
}).ToList();
return final;
}

View File

@@ -23,6 +23,23 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
EditCheckout GetDetails(long id);
Task CreateCkeckout(Checkout command);
/// <summary>
/// لود لیست اولیه جهت ایجاد فیش حقوقی
/// </summary>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId, string year,
string month,
string contractStart, string contractEnd);
//void CreateCkeckout(Checkout command);
Task<List<CheckoutViewModel>> Search(CheckoutSearchModel searchModel);

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.Domain;
using AccountManagement.Application.Contracts.Account;
using System.Threading.Tasks;
namespace Company.Domain.ContarctingPartyAgg;
@@ -42,6 +43,34 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
#endregion
/// <summary>
/// لیست طرف حساب ها
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel);
/// <summary>
/// لیست طرف حساب برای سلکت لیست سرچ
/// </summary>
/// <returns></returns>
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
/// <summary>
/// لیستی از شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
/// </summary>
/// <returns></returns>
Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId();
/// <summary>
/// غیرفعال کردن طرف حساب و زیرمجموعه های آن
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<OperationResult<string>> DeactivateWithSubordinates(long id);
void Remove(PersonalContractingParty entity);
Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id);
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
}

View File

@@ -25,7 +25,7 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
double GetcontractAmount(int countPerson);
string ExpColor(DateTime contractEndGr, double contractAmount,
(string result, string isExpier) ExpColor(DateTime contractEndGr, double contractAmount,
string isActiveString);
TotalbalancViewModel TotalBalance(long contractingPartyId);

View File

@@ -60,4 +60,13 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
#region client
List<InsuranceListViewModel> SearchForClient(InsuranceListSearchModel searchModel);
#endregion
}
#region Mahan
Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id);
Task<InsuranceListTabsCountViewModel> GetTabCounts(long accountId,int month,int year);
#endregion
}

View File

@@ -4,7 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Domain;
using Company.Domain.InsuranceListAgg.ValueObjects;
using Company.Domain.InsuranceWorkshopAgg;
using CompanyManagment.App.Contracts.InsuranceList.Enums;
namespace Company.Domain.InsuranceListAgg;
@@ -151,6 +153,21 @@ public class InsuranceList : EntityBase
/// </summary>
public double SumOfMarriedAllowance { get; private set; }
#region Mahan
/// <summary>
/// بازرسی
/// </summary>
public InsuranceListInspection Inspection { get; set; } =new (InsuranceListInspectionType.None,DateTime.MinValue, 0);
/// <summary>
/// بدهی
/// </summary>
public InsuranceListDebt Debt { get; set; } = new(InsuranceListDebtType.None, DateTime.MinValue, 0, 0);
/// <summary>
/// تاییدیه کارفرما
/// </summary>
public InsuranceListEmployerApproval EmployerApproval { get; set; } = new(InsuranceListEmployerApprovalStatus.None, string.Empty);
#endregion
public List<InsuranceListWorkshop> InsuranceListWorkshops { get; set; }
public void Edit(int sumOfEmployees, int sumOfWorkingDays, double sumOfSalaries, double sumOfBenefitsIncluded, double included,
@@ -174,4 +191,22 @@ public class InsuranceList : EntityBase
SumOfDailyWagePlusBaseYears = sumOfDailyWage + sumOfBaseYears;
}
}
public void SetDebt(InsuranceListDebt debt)
{
Debt = debt;
}
public void SetInspection(InsuranceListInspection inspection)
{
Inspection = inspection;
}
public void SetEmployerApproval(InsuranceListEmployerApproval employerApproval)
{
EmployerApproval = employerApproval;
}
public void SetConfirmSentlist(bool confirmSentlist)
{
ConfirmSentlist = confirmSentlist;
}
}

View File

@@ -0,0 +1,31 @@
using System;
using CompanyManagment.App.Contracts.InsuranceList.Enums;
namespace Company.Domain.InsuranceListAgg.ValueObjects;
public class InsuranceListDebt
{
public InsuranceListDebt(InsuranceListDebtType type, DateTime debtDate, double amount, long mediaId)
{
Type = type;
if (type == InsuranceListDebtType.None)
{
DebtDate = DateTime.MinValue;
Amount = 0;
MediaId = 0;
}
else
{
DebtDate = debtDate;
Amount = amount;
MediaId = mediaId;
IsDone = true;
}
}
public InsuranceListDebtType Type { get; set; }
public DateTime DebtDate { get; set; }
public double Amount { get; set; }
public long MediaId { get; set; }
public bool IsDone { get; set; }
}

View File

@@ -0,0 +1,26 @@
using System.Security.Cryptography;
using CompanyManagment.App.Contracts.InsuranceList.Enums;
namespace Company.Domain.InsuranceListAgg.ValueObjects;
public class InsuranceListEmployerApproval
{
public InsuranceListEmployerApproval(InsuranceListEmployerApprovalStatus status, string description)
{
Status = status;
if (status == InsuranceListEmployerApprovalStatus.None)
{
Description = string.Empty;
}
else
{
Description = description;
IsDone = true;
}
}
public InsuranceListEmployerApprovalStatus Status { get; set; }
public string Description { get; set; }
public bool IsDone { get; set; }
}

View File

@@ -0,0 +1,29 @@
using System;
using CompanyManagment.App.Contracts.InsuranceList.Enums;
namespace Company.Domain.InsuranceListAgg.ValueObjects;
public class InsuranceListInspection
{
public InsuranceListInspection(InsuranceListInspectionType type, DateTime lastInspectionDateTime, long mediaId)
{
Type = type;
if (type == InsuranceListInspectionType.None)
{
LastInspectionDateTime = DateTime.MinValue;
MediaId = 0;
}
else
{
LastInspectionDateTime = lastInspectionDateTime;
MediaId = mediaId;
IsDone = true;
}
}
public InsuranceListInspectionType Type { get; set; }
public DateTime LastInspectionDateTime { get; set; }
public long MediaId { get; set; }
public bool IsDone { get; set; }
}

View File

@@ -52,5 +52,8 @@ public interface ILeftWorkInsuranceRepository : IRepository<long, LeftWorkInsura
/// <returns></returns>
List<LeftWorkViewModel> GetEmployeesWithContractExitOnly(long workshopId);
LeftWorkInsurance GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId);
#endregion
}

View File

@@ -16,7 +16,19 @@ namespace Company.Domain.RollCallAgg;
public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
{
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout);
TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate);
/// <summary>
/// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب
/// </summary>
/// <param name="employeeId"></param>
/// <param name="workshopId"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
(bool hasRollCall, TimeSpan sumOfSpan) GetRollCallWorkingSpan(long employeeId, long workshopId,
DateTime contractStart, DateTime contractEnd);
TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate);
List<RotatingShiftViewModel> RotatingShiftCheck(List<GroupedRollCalls> rollCallList);

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.RollCallEmployee;
@@ -6,6 +7,7 @@ namespace Company.Domain.RollCallEmployeeAgg;
public interface IRollCallEmployeeRepository : IRepository<long, RollCallEmployee>
{
bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId);
EditRollCallEmployee GetDetails(long id);
RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId);

View File

@@ -56,6 +56,16 @@ public interface IEmployerRepository : IRepository<long, Employer>
#endregion
#region Api
Task<List<GetEmployerListViewModel>> GetEmployerList(GetEmployerSearchModel searchModel);
Task<GetLegalEmployerDetailViewModel> GetLegalEmployerDetail(long id);
Task<GetRealEmployerDetailViewModel> GetRealEmployerDetail(long id);
//Task<List<EmployerSelectListViewModel>> GetSelectList(string search);
Task<OperationResult<string>> DeactivateWithSubordinates(long id);
#endregion
}

View File

@@ -67,6 +67,7 @@ public class AdminMonthlyOverviewListViewModel
public long WorkshopId { get; set; }
public string WorkshopName { get; set; }
public string WorkshopArchiveCode { get; set; }
public int WorkshopArchiveCodeInt { get; set; }
public string Province { get; set; }
public string City { get; set; }
public string Address { get; set; }
@@ -74,7 +75,8 @@ public class AdminMonthlyOverviewListViewModel
public string AdminFullName { get; set; }
public string EmployerName { get; set; }
public string EmployerPhoneNumber { get; set; }
public int EmployeeCount { get; set; }
public int ContractEmployeeCount { get; set; }
public int CheckoutEmployeeCount { get; set; }
public AdminMonthlyOverviewStatus Status { get; set; }
public bool IsBlock { get; set; }
}

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Checkout;
public class CreateCheckoutListViewModel
{
public long Id { get; set; }
public long PersonnelCode { get; set; }
public long EmployeeId { get; set; }
public string ContractNo { get; set; }
public string EmployerName { get; set; }
public string WorkshopName { get; set; }
public string EmployeeName { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public string LeftWorkDate { get; set; }
//public string NextMonthStart { get; set; }
//public bool RedColor { get; set; }
public bool LaterThanEnd { get; set; }
public bool Extension { get; set; }
public bool HasCheckout { get; set; }
//public bool MoreThanOneMonth { get; set; }
//public bool Waiting { get; set; }
public string Description { get; set; }
public List<CreateCheckoutListViewModel> CreateCheckoutList { get; set; }
}

View File

@@ -13,7 +13,20 @@ public interface ICheckoutApplication
OperationResult Edit(EditCheckout command);
EditCheckout GetDetails(long id);
/// <summary>
/// لود لیست اولیه جهت ایجاد فیش حقوقی
/// </summary>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId, string year,
string month,
string contractStart, string contractEnd);
Task<List<CheckoutViewModel>> Search(CheckoutSearchModel searchModel);
List<CheckoutViewModel> SimpleSearch(CheckoutSearchModel searchModel);
List<CheckoutViewModel> PrintAll(List<long> id);

View File

@@ -0,0 +1,84 @@
using System.ComponentModel.DataAnnotations;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// ایجاد کارفرمای حقیقی
/// </summary>
public class CreateLegalEmployer
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
[Required]
public long ContractingPartyId { get; set; }
/// <summary>
/// نام شرکت
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// شناسه ملی
/// </summary>
public string NationalId { get; set; }
/// <summary>
/// شماره ثبت
/// </summary>
public string RegisterId { get; set; }
/// <summary>
/// شماره تلفن همراه
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن ثابت
/// </summary>
public string TelephoneNumber { get; set; }
/// <summary>
/// نام مدیر عامل
/// </summary>
public string EmployerFName { get; set; }
/// <summary>
/// نام خانوادگی مدیر عامل
/// </summary>
public string EmployerLName { get; set; }
/// <summary>
/// جنسیت مدیر عامل
/// </summary>
public Gender EmployerGender { get; set; }
/// <summary>
/// کد ملی مدیر عامل
/// </summary>
public string EmployerNationalCode { get; set; }
/// <summary>
/// شماره شناسنامه مدیر عامل
/// </summary>
public string EmployerIdNumber { get; set; }
/// <summary>
/// نام پدر مدیر عامل
/// </summary>
public string EmployerFatherName { get; set; }
/// <summary>
/// تاریخ تولد مدیر عامل
/// </summary>
public string EmployerDateOfBirth { get; set; }
/// <summary>
/// تاریخ صدور شناسنامه مدیر عامل
/// </summary>
public string EmployerDateOfIssue { get; set; }
/// <summary>
/// محل صدور شناسنامه مدیر عامل
/// </summary>
public string EmployerPlaceOfIssue { get; set; }
/// <summary>
/// اطلاعات سامانه ای
/// </summary>
public GovernmentSystemInfo GovernmentSystemInfo { get; set; }
}

View File

@@ -0,0 +1,80 @@
using System.ComponentModel.DataAnnotations;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// ایجاد کارفرما حقیقی
/// </summary>
public class CreateRealEmployer
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
[Required]
public long ContractingPartyId { get; set; }
/// <summary>
/// جنسیت
/// </summary>
[Required]
public Gender Gender { get; set; }
/// <summary>
/// نام
/// </summary>
[Required]
public string FName { get; set; }
/// <summary>
///نام خانوادگی
/// </summary>
[Required]
public string LName { get; set; }
/// <summary>
/// کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// شماره تلفن همراه
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن ثابت
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// تاریخ صدور شناسنامه
/// </summary>
public string DateOfIssue { get; set; }
/// <summary>
/// محل صدور شناسنامه
/// </summary>
public string PlaceOfIssue { get; set; }
/// <summary>
/// تاریخ تولد
/// </summary>
public string DateOfBirth { get; set; }
/// <summary>
/// نام پدر
/// </summary>
public string FatherName { get; set; }
/// <summary>
/// اطلاعات سامانه ای
/// </summary>
public GovernmentSystemInfo GovernmentSystemInfo { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace CompanyManagment.App.Contracts.Employer;
public class EditLegalEmployer: CreateLegalEmployer
{
/// <summary>
/// آیدی کارفرما
/// </summary>
public long Id { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// ویرایش کارفرما حقیقی
/// </summary>
public class EditRealEmployer:CreateRealEmployer
{
/// <summary>
/// آیدی کارفرما
/// </summary>
public long Id { get; set; }
}

View File

@@ -0,0 +1,50 @@
using System.Collections.Generic;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// مدل برای گرفتن لیست کارفرما
/// </summary>
public class GetEmployerListViewModel
{
/// <summary>
/// آیدی کارفرما
/// </summary>
public long Id { get; set; }
/// <summary>
/// کدملی / شناسه ملی
/// </summary>
public string NationalCodeOrNationalId { get; set; }
/// <summary>
/// نام کارفرما
/// </summary>
public string FullName { get; set; }
/// <summary>
/// نام های کارگاه
/// </summary>
public ICollection<string> WorkshopNames { get; set; }
/// <summary>
/// دارای طرف حساب
/// </summary>
public bool HasContractingParty { get; set; }
/// <summary>
/// طرف حساب بلاک شده یا نه
/// </summary>
public bool HasBlockContractingParty { get; set; }
/// <summary>
/// نوع کارفرما
/// </summary>
public LegalType LegalType { get; set; }
/// <summary>
/// وضعیت کارفرما
/// </summary>
public ActivationStatus EmployerStatus { get; set; }
}

View File

@@ -0,0 +1,44 @@
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// مدل جستجوی لیست کارفرما
/// </summary>
public class GetEmployerSearchModel
{
/// <summary>
/// نام شرکت / نام و نام خانوادگی
/// </summary>
public string FullNameOrCompanyName { get; set; }
/// <summary>
/// کدملی/ شناسه ملی
/// </summary>
public string NationalCodeOrNationalId { get; set; }
/// <summary>
/// شماره شناسنامه یا شماره ثبت
/// </summary>
public string IdNumberOrRegisterId { get; set; }
/// <summary>
/// نام طرف حساب
/// </summary>
public string ContractingPartyName { get; set; }
/// <summary>
/// وضعیت کارفرما
/// </summary>
public ActivationStatus EmployerStatus { get; set; }
/// <summary>
/// نوع کارفرما
/// </summary>
public LegalType EmployerType { get; set; }
/// <summary>
/// پیج ایندکس برای دسته بندی سی تایی
/// </summary>
public int PageIndex { get; set; }
}

View File

@@ -0,0 +1,120 @@
using _0_Framework.Application;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// اطلاعات کارفرمای حقوقی
/// </summary>
public class GetLegalEmployerDetailViewModel
{
/// <summary>
/// آیدی کارفرما
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام شرکت
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// شناسه ملی
/// </summary>
public string NationalId { get; set; }
/// <summary>
/// شماره ثبت
/// </summary>
public string RegisterId { get; set; }
/// <summary>
/// شماره تلفن همراه
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن ثابت
/// </summary>
public string TelephoneNumber { get; set; }
/// <summary>
/// کد کارفرما
/// </summary>
public string EmployerNo { get; set; }
/// <summary>
/// نام کارفرما
/// </summary>
public string ContractingPartyName { get; set; }
/// <summary>
/// نام کارفرما
/// </summary>
public long ContractingPartyId { get; set; }
/// <summary>
/// نام و خانوادگی مدیر عامل
/// </summary>
public string CeoFullName { get; set; }
/// <summary>
/// نام و خانوادگی مدیر عامل
/// </summary>
public string CeoFName { get; set; }
/// <summary>
/// نام و خانوادگی مدیر عامل
/// </summary>
public string CeoLName { get; set; }
/// <summary>
/// جنسیت مدیر عامل
/// </summary>
public Gender Gender { get; set; }
/// <summary>
/// جنیست
/// </summary>
public string GenderStr { get; set; }
/// <summary>
/// ملیت
/// </summary>
public string Nationality { get; set; }
/// <summary>
/// نام پدر
/// </summary>
public string FatherName { get; set; }
/// <summary>
/// کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// تاریخ تولد
/// </summary>
public string DateOfBirth { get; set; }
/// <summary>
/// تاریخ صدور شناسنامه
/// </summary>
public string DateOfIssue { get; set; }
/// <summary>
/// محل صدور شناسنامه
/// </summary>
public string PlaceOfIssue { get; set; }
/// <summary>
/// اطلاعات سامانه های دولتی
/// </summary>
public GovernmentSystemInfo GovernmentSystemInfo { get; set; }
}

View File

@@ -0,0 +1,107 @@
using _0_Framework.Application;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// اطلاعات کارفرمای حقوقی
/// </summary>
public class GetRealEmployerDetailViewModel
{
/// <summary>
/// آیدی کارفرما
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام و نام خانوادگی
/// </summary>
public string FullName { get; set; }
/// <summary>
/// نام
/// </summary>
public string FName{ get; set; }
/// <summary>
/// نام خانوادگی
/// </summary>
public string LName { get; set; }
/// <summary>
/// کدملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// جنسیت فارسی
/// </summary>
public string GenderStr { get; set; }
/// <summary>
/// جنسیت
/// </summary>
public Gender Gender { get; set; }
/// <summary>
/// ملیت
/// </summary>
public string Nationality { get; set; }
/// <summary>
/// شماره تلفن همراه
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// نام پدر
/// </summary>
public string FatherName { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// تاریخ تولد
/// </summary>
public string DateOfBirth { get; set; }
/// <summary>
/// نام طرف حساب
/// </summary>
public string ContractingPartyName { get; set; }
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long ContractingPartyId { get; set; }
/// <summary>
/// کد کارفرما
/// </summary>
public string EmployerNo { get; set; }
/// <summary>
/// شماره تلفن ثابت
/// </summary>
public string TelephoneNumber { get; set; }
/// <summary>
/// تاریخ صدور شناسنامه
/// </summary>
public string DateOfIssue { get; set; }
/// <summary>
/// محل صدور شناسنامه
/// </summary>
public string PlaceOfIssue { get; set; }
/// <summary>
/// اطلاعات سامانه های دولتی
/// </summary>
public GovernmentSystemInfo GovernmentSystemInfo { get; set; }
}

View File

@@ -0,0 +1,54 @@
using System;
namespace CompanyManagment.App.Contracts.Employer;
/// <summary>
/// اطلاعات سامانه های دولتی
/// </summary>
public class GovernmentSystemInfo
{
#region MCL
/// <summary>
/// نام کاربری اداره کار
/// </summary>
public string MclUsername { get; set; }
/// <summary>
/// رمز عبور اداره کار
/// </summary>
public string MclPassword { get; set; }
#endregion
#region E-Service تامین اجتماعی
/// <summary>
/// نام کاربری سازمان تامین اجتماعی
/// </summary>
public string EServiceUsername { get; set; }
/// <summary>
/// رمز عبور سازمان تامین اجتماعی
/// </summary>
public string EServicePassword { get; set; }
#endregion
#region Tax سامانه مالیاتی
/// <summary>
/// نام کاربری سامانه مالیاتی
/// </summary>
public string TaxUsername { get; set; }
/// <summary>
/// رمز عبور سامانه مالیاتی
/// </summary>
public string TaxPassword { get; set; }
#endregion
#region Sana سامانه ثنا
/// <summary>
/// نام کاربری ثنا
/// </summary>
public string SanaUsername { get; set; }
/// <summary>
/// رمز عبور ثنا
/// </summary>
public string SanaPassword { get; set; }
#endregion
}

View File

@@ -55,4 +55,71 @@ public interface IEmployerApplication
#endregion
}
#region Api
/// <summary>
/// لیست کارفرما ها
/// </summary>
/// <returns></returns>
Task<List<GetEmployerListViewModel>> GetEmployerList(GetEmployerSearchModel searchModel);
/// <summary>
/// جزئیات کارفرما حقوقی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<GetLegalEmployerDetailViewModel> GetLegalEmployerDetail(long id);
/// <summary>
/// جزئیات کارفرما حقیقی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<GetRealEmployerDetailViewModel> GetRealEmployerDetail(long id);
/// <summary>
/// ایجاد کارفرمای حقیقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateReal(CreateRealEmployer command);
/// <summary>
/// ایجاد کارفرمای حقوقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateLegal(CreateLegalEmployer command);
/// <summary>
/// ویرایش کارفرمای حقیقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> EditReal(EditRealEmployer command);
/// <summary>
/// ویرایش کارفرمای حقوقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> EditLegal(EditLegalEmployer command);
///// <summary>
///// لیست نام کارفرما ها برای جستجو
///// </summary>
///// <param name="search"></param>
///// <returns></returns>
//public Task<List<EmployerSelectListViewModel>> GetSelectList(string search);
/// <summary>
/// حذف کارفرما - درصورت داشتن کارگاه کارفرما غیرفعال میشود
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Task<OperationResult<string>> RemoveApi(long id);
#endregion
}

View File

@@ -69,4 +69,5 @@ public class InstitutionContractViewModel
public double ValueAddedTax { get; set; }
public int LeftWorkEmployeeCount { get; set; }
public int InsuranceLeftWorkEmployeeCount { get; set; }
public string IsExpier { get; set; }
}

View File

@@ -14,9 +14,6 @@ public class EditInsuranceList:CreateInsuranceList
public bool FixedSalary { get; set; }
public string Population { get; set; }
public long? InsuranceJobId { get; set; }
/// <summary>
/// پرسنل هایی که قرارداد ترک کار کرده اند ولی ترک کار بیمه ندارند
/// </summary>
public List<LeftWorkViewModel> LeftWorkEmployees { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace CompanyManagment.App.Contracts.InsuranceList.Enums;
public enum InsuranceListDebtType
{
None,
Old,
New
}

View File

@@ -0,0 +1,14 @@
namespace CompanyManagment.App.Contracts.InsuranceList.Enums;
public enum InsuranceListEmployerApprovalStatus
{
None,
/// <summary>
/// تاییدیه شفاهی (اذنی)
/// </summary>
VerbalApproval,
/// <summary>
/// تاییدیه کاغذی
/// </summary>
WrittenApproval
}

View File

@@ -0,0 +1,8 @@
namespace CompanyManagment.App.Contracts.InsuranceList.Enums;
public enum InsuranceListInspectionType
{
None,
Old,
New
}

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.InsuranceList;
using Microsoft.AspNetCore.Http;
namespace CompanyManagment.App.Contracts.InsuranceList;
@@ -17,9 +18,9 @@ public interface IInsuranceListApplication
MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList(EmployeeForCreateInsuranceListSearchModel searchModel);
double MarriedAllowance(string maritalStatus, long jobId, bool includedStatus,
int countWorkingDays, double marriedAlowance, int endMonthCurrentDay);
int countWorkingDays, double marriedAlowance, int endMonthCurrentDay);
OperationResult CreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command);
OperationResult CreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command);
OperationResult EditEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command);
OperationResult Remove(long id);
EditInsuranceList GetDetailsForEdit(long id);
@@ -34,4 +35,16 @@ public interface IInsuranceListApplication
//farokhiChanges
(double basic, int totalYear) BasicYear(long employeeId, long worshopId, DateTime startDate);
double GetMonthlyBaseYear(double dayliBase, int countWorkingDays);
#region Mahan
/// <summary>
/// مراحل اجرایی برای تکمیل و ارسال لیست بیمه
/// </summary>
/// <returns></returns>
Task<OperationResult> ConfirmInsuranceOperation(InsuranceListConfirmOperation command);
Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id);
Task<InsuranceListTabsCountViewModel> GetTabCounts(long accountId, int month, int year);
#endregion
}

View File

@@ -0,0 +1,48 @@
using CompanyManagment.App.Contracts.InsuranceList.Enums;
using Microsoft.AspNetCore.Http;
namespace CompanyManagment.App.Contracts.InsuranceList;
public class InsuranceListConfirmOperation
{
public long InsuranceListId { get; set; }
/// <summary>
/// بازرسی
/// </summary>
public CreateInsuranceListInspection Inspection { get; set; }
/// <summary>
/// بدهی
/// </summary>
public CreateInsuranceListDebt Debt { get; set; }
/// <summary>
/// تاییدیه کارفرما
/// </summary>
public CreateInsuranceListApproval Approval { get; set; }
public bool ConfirmSentList { get; set; }
}
public class CreateInsuranceListApproval
{
public InsuranceListEmployerApprovalStatus ApprovalStatus { get; set; }
public string Description { get; set; }
}
public class CreateInsuranceListDebt
{
public InsuranceListDebtType Type { get; set; }
public string DebtDate { get; set; }
public string Amount { get; set; }
public IFormFile DebtFile { get; set; }
public long DebtFileMediaId { get; set; }
public string FilePath { get; set; }
}
public class CreateInsuranceListInspection
{
public InsuranceListInspectionType Type { get; set; }
public string LastInspectionDate { get; set; }
public IFormFile InspectionFile { get; set; }
public long InspectionFileMediaId { get; set; }
public string FilePath { get; set; }
}

View File

@@ -25,4 +25,29 @@ public class InsuranceListSearchModel
public int PageIndex { get; set; }
public bool SearchAll { get; set; }
public InsuranceListSearchStatus Status { get; set; }
}
public enum InsuranceListSearchStatus
{
/// <summary>
/// انجام نشده
/// </summary>
NotStarted = 0,
/// <summary>
/// در حال انجام امور
/// </summary>
InProgress = 1,
/// <summary>
/// آماده ارسال لیست
/// </summary>
ReadyToSendList = 2,
/// <summary>
/// انجام بیمه
/// </summary>
Done = 3
}

View File

@@ -0,0 +1,24 @@
namespace CompanyManagment.App.Contracts.InsuranceList;
public class InsuranceListTabsCountViewModel
{
/// <summary>
/// انجام نشده
/// </summary>
public int NotStarted { get; set; }
/// <summary>
/// در حال انجام امور
/// </summary>
public int InProgress { get; set; }
/// <summary>
/// آماده ارسال لیست
/// </summary>
public int ReadyToSendList { get; set; }
/// <summary>
/// انجام بیمه
/// </summary>
public int Done { get; set; }
}

View File

@@ -27,4 +27,11 @@ public class InsuranceListViewModel
public long WorkShopId { get; set; }
public string IsBlockCantracingParty { get; set; }
public long EmployerId { get; set; }
/// <summary>وضعیت بازرسی</summary>
public bool InspectionDone { get; set; }
/// <summary>وضعیت بدهی</summary>
public bool DebtDone { get; set; }
/// <summary>وضعیت تاییدیه کارفرما</summary>
public bool EmployerApproved { get; set; }
}

View File

@@ -0,0 +1,37 @@
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
public class ContractingPartyGetListSearchModel
{
/// <summary>
/// تعدادی که برای لیست بعدی آیتم باید رد کنه
/// </summary>
public int PageIndex { get; set; }
/// <summary>
/// نام شرکت یا نام و نام خانوادگی طرف حساب
/// </summary>
public string FullNameOrCompanyName { get; set; }
/// <summary>
/// شناسه ملی یا شماره ملی
/// </summary>
public string NationalIdOrNationalCode { get; set; }
/// <summary>
/// نام معرف
/// </summary>
public string RepresentativeName { get; set; }
/// <summary>
/// نوع طرف حساب
/// </summary>
public LegalType ContractingPartyType { get; set; }
/// <summary>
/// وضعیت طرف حساب
/// </summary>
public ActivationStatus ContractingPartyStatus { get; set; }
}

View File

@@ -0,0 +1,60 @@
using System.Collections.Generic;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
public record ContractingPartyGetListEmployerViewModel(long EmployerId, string EmployerName);
public class ContractingPartyGetListViewModel
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long Id { get; set; }
/// <summary>
/// کد طرف حساب
/// </summary>
public int ArchiveCode { get; set; }
/// <summary>
/// شناسه ملی یا شماره ملی
/// </summary>
public string NationalIdOrNationalCode { get; set; }
/// <summary>
/// نام طرف حساب
/// </summary>
public string ContractingPartyName { get; set; }
/// <summary>
/// لیست کارفرما ها
/// </summary>
public ICollection<ContractingPartyGetListEmployerViewModel> Employers { get; set; }
/// <summary>
/// تعداد بلاک
/// </summary>
public int BlockTimes { get; set; }
/// <summary>
/// آیا بلاک هست
/// </summary>
public bool IsBlock { get; set; }
/// <summary>
/// آیا دارای قرارداد مالی است
/// </summary>
public bool HasInstitutionContract { get; set; }
/// <summary>
/// نوع طرف حساب
/// </summary>
public LegalType ContractingPartyType { get; set; }
/// <summary>
/// وضعیت طرف حساب
/// </summary>
public ActivationStatus Status { get; set; }
}

View File

@@ -0,0 +1,8 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
public class ContractingPartySelectListViewModel: SelectListViewModel
{
}

View File

@@ -0,0 +1,74 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
public class CreateLegalContractingParty
{
/// <summary>
/// آیدی معرف
/// </summary>
[Required]
public long RepresentativeId { get; set; }
/// <summary>
/// نام شرکت
/// </summary>
[Required]
public string CompanyName { get; set; }
/// <summary>
/// شناسه ملی
/// </summary>
[Required]
public string NationalId { get; set; }
/// <summary>
/// کد طرف حساب
/// </summary>
[Required]
public int ArchiveCode { get; set; }
/// <summary>
/// نام مستعار
/// </summary>
public string SureName { get; set; }
/// <summary>
/// شماره ثبت
/// </summary>
public string RegisterId { get; set; }
/// <summary>
/// شماره تلفن
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن نماینده
/// </summary>
public string AgentPhone { get; set; }
/// <summary>
/// استان
/// </summary>
public string State { get; set; }
/// <summary>
/// شهر
/// </summary>
public string City { get; set; }
/// <summary>
/// محله
/// </summary>
public string Zone { get; set; }
/// <summary>
/// نشانی
/// </summary>
public string Address { get; set; }
}

View File

@@ -0,0 +1,77 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
public class CreateRealContractingParty
{
/// <summary>
/// نام
/// </summary>
[Required]
public string FName { get; set; }
/// <summary>
/// نام خانوادگی
/// </summary>
[Required]
public string LName { get; set; }
/// <summary>
/// آیدی معرف
/// </summary>
[Required]
public long RepresentativeId { get; set; }
/// <summary>
/// کد ملی
/// </summary>
[Required]
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
[Required]
public string IdNumber { get; set; }
/// <summary>
/// کد طرف حساب
/// </summary>
[Required]
public int ArchiveCode { get; set; }
/// <summary>
/// نام مستعار
/// </summary>
public string SureName { get; set; }
/// <summary>
/// شماره تلفن
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن نماینده
/// </summary>
public string AgentPhone { get; set; }
/// <summary>
/// استان
/// </summary>
public string State { get; set; }
/// <summary>
/// شهر
/// </summary>
public string City { get; set; }
/// <summary>
/// محله
/// </summary>
public string Zone { get; set; }
/// <summary>
/// نشانی
/// </summary>
public string Address { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
/// <summary>
/// ویرایش طرف حساب حقوقی
/// </summary>
public class EditLegalContractingParty:CreateLegalContractingParty
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long Id { get; set; }
}

View File

@@ -0,0 +1,13 @@
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
/// <summary>
/// ویرایش طرف حساب حقیقی
/// </summary>
public class EditRealContractingParty:CreateRealContractingParty
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long Id { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
/// <summary>
/// شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
/// </summary>
public class GetContractingPartyNationalCodeOrNationalIdViewModel
{
/// <summary>
/// شماره ملی یا شناسه ملی
/// </summary>
public string NationalCodeOrNationalId { get; set; }
}

View File

@@ -0,0 +1,83 @@
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
/// <summary>
/// ویو مدل جزئیات طرف حساب حقوقی
/// </summary>
public class GetLegalContractingPartyDetailsViewModel
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام کامل شرکت(به همراه نام مستعار)ء
/// </summary>
public string CompanyFullName { get; set; }
/// <summary>
/// نام شرکت (بدون نام مستعار)ء
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// نام مستعار
/// </summary>
public string SureName { get; set; }
/// <summary>
/// شماره ثبت
/// </summary>
public string RegisterId { get; set; }
/// <summary>
/// شماره ملی
/// </summary>
public string NationalId { get; set; }
/// <summary>
/// شماره تماس
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تماس نماینده
/// </summary>
public string AgentPhone { get; set; }
/// <summary>
/// آدرس
/// </summary>
public string Address { get; set; }
/// <summary>
/// معرف
/// </summary>
public string RepresentativeName { get; set; }
/// <summary>
/// آیدی معرف
/// </summary>
public long RepresentativeId { get; set; }
/// <summary>
/// کد طرف حساب
/// </summary>
public int ArchiveCode { get; set; }
/// <summary>
/// استان
/// </summary>
public string State { get; set; }
/// <summary>
/// شهر
/// </summary>
public string City { get; set; }
/// <summary>
/// محله
/// </summary>
public string Zone { get; set; }
}

View File

@@ -0,0 +1,94 @@
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Builder;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
/// <summary>
/// ویو مدل جزئیات طرف حساب حقیقی
/// </summary>
public class GetRealContractingPartyDetailsViewModel
{
/// <summary>
/// آیدی طرف حساب
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام
/// </summary>
public string FName { get; set; }
/// <summary>
/// نام خانوادگی
/// </summary>
public string LName { get; set; }
/// <summary>
/// نام و نام خانوادگی
/// </summary>
public string FullName { get; set; }
/// <summary>
/// کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// شماره تلفن
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// شماره تلفن نماینده
/// </summary>
public string AgentPhone { get; set; }
/// <summary>
/// آدرس
/// </summary>
public string Address { get; set; }
/// <summary>
/// نام معرف
/// </summary>
public string RepresentativeName { get; set; }
/// <summary>
/// آیدی معرف
/// </summary>
public long RepresentativeId { get; set; }
/// <summary>
/// نام مستعار
/// </summary>
public string SureName { get; set; }
/// <summary>
/// کد طرف حساب
/// </summary>
public int ArchiveCode { get; set; }
/// <summary>
/// استان
/// </summary>
public string State { get; set; }
/// <summary>
/// شهر
/// </summary>
public string City { get; set; }
/// <summary>
/// محله
/// </summary>
public string Zone { get; set; }
}

View File

@@ -1,5 +1,6 @@
using _0_Framework.Application;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.PersonalContractingParty;
@@ -54,4 +55,79 @@ public interface IPersonalContractingPartyApp
#endregion
#region Api
/// <summary>
/// لیست طرف حساب ها
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel);
/// <summary>
/// لیست طرف حساب برای سلکت لیست سرچ
/// </summary>
/// <returns></returns>
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
/// <summary>
/// ایجاد طرف حساب حقیقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateReal(CreateRealContractingParty command);
/// <summary>
/// ایجاد ظرف حساب حقوقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateLegal(CreateLegalContractingParty command);
/// <summary>
/// لیستی از شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن
/// </summary>
/// <returns></returns>
Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId();
/// <summary>
/// حذف طرف حساب. در صورتی که طرف حساب دارای قرارداد مالی یا دارای کارفرما باشد غیرفعال میشود
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<OperationResult<string>> Delete(long id);
/// <summary>
/// ویرایش طرف حساب حقیقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
OperationResult EditRealApi(EditRealContractingParty command);
/// <summary>
/// ویرایش طرف حساب حقوقی
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
OperationResult EditLegal(EditLegalContractingParty command);
/// <summary>
/// گرفتن جزئیات طرف حساب حقوقی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id);
/// <summary>
/// گرفتن جزئیات طرف حساب حقوقی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
#endregion
}

View File

@@ -47,4 +47,6 @@ public class PersonalContractingPartyViewModel
public bool IsAuthenticated { get; set; }
public List<EmployerViewModel> EmployerList { get; set; }
}

View File

@@ -38,4 +38,5 @@ public interface IRollCallEmployeeApplication
(int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId);
bool HasEmployees(long workshopId);
#endregion
}

View File

@@ -17,5 +17,7 @@ namespace CompanyManagment.App.Contracts.RollCallEmployeeStatus
List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr);
bool IsActiveInPeriod(long employeeId, long workshopId, DateTime startDate, DateTime endDate);
}
void SyncRollCallEmployeeWithLeftWork(long rollCallEmployeeId);
}
}

View File

@@ -6,6 +6,8 @@ public class SalaryAidGroupedByDateViewModel
{
public string MonthFa { get; set; }
public string YearFa { get; set; }
public int Month { get; set; }
public int Year { get; set; }
public List<SalaryAidGroupedByDateViewModelItems> SalaryAidViewModels { get; set; }
public string TotalAmount { get; set; }

View File

@@ -15,7 +15,8 @@ public class SalaryAidViewModel
public string CalculationDateTimeFa { get; set; }
public DateTime CalculationDateTimeGe { get; set; }
public int Month { get; set; }
public int Year { get; set; }
public string EmployeeFullName { get; set; }
public string PersonnelCode { get; set; }

View File

@@ -7,5 +7,6 @@ namespace CompanyManagment.App.Contracts.Workshop
public string WorkshopName { get; set; }
public long SubAccountId { get; set; }
public string IsActive { get; set; }
public int PersonnelCount { get; set; }
}
}

View File

@@ -55,7 +55,7 @@ namespace CompanyManagment.Application
if(command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length >0 )
{
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"]);
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"], "Bank");
if (uploadResult.IsSuccedded == false)
return uploadResult;
mediaId = uploadResult.SendId;
@@ -81,7 +81,7 @@ namespace CompanyManagment.Application
if (command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length > 0)
{
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"]);
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"], "Bank");
if (uploadResult.IsSuccedded == false)
return uploadResult;
_mediaApplication.DeleteFile(entity.BankLogoMediaId);

View File

@@ -239,6 +239,13 @@ public class CheckoutApplication : ICheckoutApplication
return _checkoutRepository.GetDetails(id);
}
public async Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId, string year, string month,
string contractStart, string contractEnd)
{
return await _checkoutRepository.GetContractResultToCreateCheckout(workshopId, employeeId, year, month, contractStart,
contractEnd);
}
public async Task<List<CheckoutViewModel>> Search(CheckoutSearchModel searchModel)
{
var result = new List<CheckoutViewModel>();

View File

@@ -33,6 +33,7 @@ using System.Reflection;
using Company.Domain.EmployeeAuthorizeTempAgg;
using Company.Domain.RollCallServiceAgg;
using Microsoft.Extensions.Configuration;
using Company.Domain.LeftWorkInsuranceAgg;
namespace CompanyManagment.Application;
@@ -61,22 +62,29 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
private readonly IUidService _uidService;
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
private readonly IEmployeeAuthorizeTempRepository _employeeAuthorizeTempRepository;
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository ;
private readonly IRollCallServiceRepository _rollCallServiceRepository;
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository,
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context,
IWorkshopRepository workShopRepository,
ILeftWorkRepository leftWorkRepository, IPersonnelCodeRepository personnelCodeRepository,
IEmployeeClientTempRepository employeeClientTempRepository, IWebHostEnvironment webHostEnvironment,
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository,
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication,
IRollCallEmployeeRepository rollCallEmployeeRepository,
ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository,
ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication,
IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository,
IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository, IRollCallServiceRepository rollCallServiceRepository) : base(context)
ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication,
IEmployeeDocumentsApplication employeeDocumentsApplication,
IEmployeeBankInformationApplication employeeBankInformationApplication,
ILeftWorkTempRepository leftWorkTempRepository,
IUidService uidService,
ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository,
IRollCallServiceRepository rollCallServiceRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository) : base(context)
{
_context = context;
_WorkShopRepository = workShopRepository;
_EmployeeRepository = employeeRepository;
this._leftWorkRepository = leftWorkRepository;
this._leftWorkRepository = leftWorkRepository;
_personnelCodeRepository = personnelCodeRepository;
_employeeClientTempRepository = employeeClientTempRepository;
_webHostEnvironment = webHostEnvironment;
@@ -89,6 +97,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_uidService = uidService;
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_EmployeeRepository = employeeRepository;
_rollCallServiceRepository = rollCallServiceRepository;
}
@@ -1030,7 +1040,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
var startLeftWork = command.StartLeftWork.ToGeorgianDateTime();
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
PersonnelCodeDomain personnelCode = null;
PersonnelCodeDomain personnelCode = null;
if (leftWorkViewModel != null)
{
if (leftWorkViewModel.HasLeft == false && leftWorkViewModel.LeftWorkDate > DateTime.Now)
@@ -1045,10 +1057,16 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}
else
{
var lastPersonnelCodeByWorkshop = _personnelCodeRepository.GetLastPersonnelCodeByWorkshop(command.WorkshopId);
var insuranceLeftWork =
_leftWorkInsuranceRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
if (insuranceLeftWork == null)
{
var lastPersonnelCodeByWorkshop =
_personnelCodeRepository.GetLastPersonnelCodeByWorkshop(command.WorkshopId);
personnelCode = new PersonnelCodeDomain(command.WorkshopId,
employee.id, lastPersonnelCodeByWorkshop + 1);
personnelCode = new PersonnelCodeDomain(command.WorkshopId,
employee.id, lastPersonnelCodeByWorkshop + 1);
}
}
var leftWorkTemp = LeftWorkTemp.CreateStartWork(command.WorkshopId, employee.id, startLeftWork, command.JobId);

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Exceptions;
using Company.Domain.empolyerAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Checkout;
@@ -957,4 +958,256 @@ public class EmployerApplication : IEmployerApplication
}
#endregion
#region Api
public async Task<List<GetEmployerListViewModel>> GetEmployerList(GetEmployerSearchModel searchModel)
{
return await _EmployerRepository.GetEmployerList(searchModel);
}
public async Task<GetLegalEmployerDetailViewModel> GetLegalEmployerDetail(long id)
{
var employer = await _EmployerRepository.GetLegalEmployerDetail(id);
if (employer == null)
{
throw new NotFoundException("کارفرمای مورد نطر یافت نشد");
}
return employer;
}
public async Task<GetRealEmployerDetailViewModel> GetRealEmployerDetail(long id)
{
var employer = await _EmployerRepository.GetRealEmployerDetail(id);
if (employer == null)
{
throw new NotFoundException("کارفرمای مورد نطر یافت نشد");
}
return employer;
}
public async Task<OperationResult> CreateReal(CreateRealEmployer command)
{
var opration = new OperationResult();
if (_EmployerRepository.Exists(x =>
(x.FName == command.FName && x.LName == command.LName) && x.Nationalcode == command.NationalCode && x.Nationalcode != null))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (string.IsNullOrWhiteSpace(command.FName))
return opration.Failed("لطفا نام را وارد کنید");
if (!string.IsNullOrWhiteSpace(command.NationalCode))
{
if (command.NationalCode.NationalCodeValid() != "valid")
{
return opration.Failed("کدملی وارد شده نامعتبر است");
}
if (_EmployerRepository.Exists(x => x.Nationalcode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode)))
{
return opration.Failed("کد ملی وارد شده تکراری است");
}
}
string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var gender = command.Gender switch
{
Gender.Male => "مرد",
Gender.Female => "زن",
Gender.None => null,
_ => throw new BadRequestException("جنسیت وارد شده نامعتبر است")
};
var employerData = new Employer(command.FName, command.LName, command.ContractingPartyId, gender,
command.NationalCode, command.IdNumber, "ایرانی", command.FatherName, dateOfBirth,
dateOfIssue, command.PlaceOfIssue, "*", "*", "*", "حقیقی", command.PhoneNumber,
command.Telephone, "true", command.GovernmentSystemInfo.MclUsername, command.GovernmentSystemInfo.MclPassword, command.GovernmentSystemInfo.EServiceUsername, command.GovernmentSystemInfo.EServicePassword,
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword, command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword);
await _EmployerRepository.CreateAsync(employerData);
await _EmployerRepository.SaveChangesAsync();
return opration.Succcedded();
}
public async Task<OperationResult> CreateLegal(CreateLegalEmployer command)
{
if (string.IsNullOrWhiteSpace(command.EmployerLName))
command.EmployerLName = "#";
var opration = new OperationResult();
if (_EmployerRepository.Exists(x =>
x.LName == command.CompanyName && x.NationalId == command.NationalId && x.EmployerLName == command.EmployerLName))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (_EmployerRepository.Exists(x => x.NationalId == command.NationalId && !string.IsNullOrWhiteSpace(command.NationalId) && x.NationalId != null))
{
return opration.Failed(" شناسه ملی وارد شده تکراری است");
}
if (_EmployerRepository.Exists(x => x.LName == command.CompanyName))
{
return opration.Failed("نام شرکت وارد شده تکراری است");
}
if (_EmployerRepository.Exists(x => x.RegisterId == command.RegisterId && !string.IsNullOrWhiteSpace(command.RegisterId) && x.RegisterId != null))
{
return opration.Failed(" شماره ثبت وارد شده تکراری است");
}
if (!string.IsNullOrEmpty(command.NationalId) && command.NationalId.Length != 11)
{
return opration.Failed(" شناسه ملی باید 11 رقم باشد");
}
if (!string.IsNullOrWhiteSpace(command.EmployerNationalCode))
{
if (command.EmployerNationalCode.NationalCodeValid() != "valid")
{
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
}
string initial = "1300/10/11";
var dateOfBirth = command.EmployerDateOfBirth?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var dateOfIssue = command.EmployerDateOfIssue?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var gender = command.EmployerGender switch
{
Gender.Male => "مرد",
Gender.Female => "زن",
Gender.None => null,
_ => throw new BadRequestException("جنسیت وارد شده نامعتبر است")
};
var legalEmployerData = new Employer(command.EmployerFName, command.CompanyName, command.ContractingPartyId, gender,
command.EmployerNationalCode, command.EmployerIdNumber, "ایرانی", command.EmployerFatherName, dateOfBirth,
dateOfIssue, command.EmployerPlaceOfIssue, command.RegisterId, command.NationalId, command.EmployerLName, "حقوقی", command.PhoneNumber,
command.TelephoneNumber, "true", command.GovernmentSystemInfo.MclUsername, command.GovernmentSystemInfo.MclPassword,
command.GovernmentSystemInfo.EServiceUsername, command.GovernmentSystemInfo.EServicePassword,
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword, command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword);
await _EmployerRepository.CreateAsync(legalEmployerData);
await _EmployerRepository.SaveChangesAsync();
return opration.Succcedded();
}
public async Task<OperationResult> EditReal(EditRealEmployer command)
{
var opration = new OperationResult();
var employer = _EmployerRepository.Get(command.Id);
if (employer == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (_EmployerRepository.Exists(x =>
(x.FName == command.FName && x.LName == command.LName) && x.Nationalcode == command.NationalCode && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (!string.IsNullOrWhiteSpace(command.NationalCode))
{
if (command.NationalCode.NationalCodeValid() != "valid")
{
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
}
if (_EmployerRepository.Exists(x => x.Nationalcode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.id != command.Id))
{
return opration.Failed(" کد ملی وارد شده تکراری است");
}
string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var gender = command.Gender switch
{
Gender.Male => "مرد",
Gender.Female => "زن",
Gender.None => null,
_ => throw new BadRequestException("جنسیت وارد شده نامعتبر است")
};
employer.Edit(command.FName, command.LName, command.ContractingPartyId,
gender, command.NationalCode, command.IdNumber, "ایرانی", command.FatherName,
dateOfBirth, dateOfIssue, command.PlaceOfIssue, command.PhoneNumber, command.Telephone,
command.GovernmentSystemInfo.MclUsername, command.GovernmentSystemInfo.MclPassword, command.GovernmentSystemInfo.EServiceUsername, command.GovernmentSystemInfo.EServicePassword,
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword, command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword, null);
await _EmployerRepository.SaveChangesAsync();
return opration.Succcedded();
}
public async Task<OperationResult> EditLegal(EditLegalEmployer command)
{
var opration = new OperationResult();
var legalEmployer = _EmployerRepository.Get(command.Id);
if (legalEmployer == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (_EmployerRepository.Exists(x =>
x.LName == command.CompanyName && x.NationalId == command.NationalId && !string.IsNullOrWhiteSpace(command.NationalId) && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (!string.IsNullOrEmpty(command.NationalId) && command.NationalId.Length != 11)
{
return opration.Failed(" شناسه ملی باید 11 رقم باشد");
}
if (!string.IsNullOrWhiteSpace(command.EmployerNationalCode))
{
if (command.EmployerNationalCode.NationalCodeValid() != "valid")
{
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
}
var gender = command.EmployerGender switch
{
Gender.Male => "مرد",
Gender.Female => "زن",
Gender.None => null,
_ => throw new BadRequestException("جنسیت وارد شده نامعتبر است")
};
string initial = "1300/10/11";
var dateOfBirth = command.EmployerDateOfBirth?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
var dateOfIssue = command.EmployerDateOfIssue?.ToGeorgianDateTime() ?? initial.ToGeorgianDateTime();
legalEmployer.EditLegal(command.EmployerFName, command.CompanyName, command.ContractingPartyId, gender,
command.EmployerNationalCode, command.EmployerIdNumber, "ایرانی", command.EmployerFatherName, dateOfBirth,
dateOfIssue, command.EmployerPlaceOfIssue, command.RegisterId, command.NationalId, command.EmployerLName,
command.PhoneNumber, command.TelephoneNumber, command.GovernmentSystemInfo.MclUsername, command.GovernmentSystemInfo.MclUsername, command.GovernmentSystemInfo.EServiceUsername, command.GovernmentSystemInfo.EServicePassword,
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword, command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword, null);
await _EmployerRepository.SaveChangesAsync();
return opration.Succcedded();
}
//public async Task<List<EmployerSelectListViewModel>> GetSelectList(string search)
//{
// return await _EmployerRepository.GetSelectList(search);
//}
async Task<OperationResult<string>> IEmployerApplication.RemoveApi(long id)
{
var employer = _EmployerRepository.Get(id);
if (employer == null)
throw new NotFoundException("دیتای مورد نظر یافت نشد");
var workshops = _workshopRepository.GetWorkshopsByEmployerId([id]);
if (workshops.Any())
{
return await _EmployerRepository.DeactivateWithSubordinates(id);
}
_EmployerRepository.Remove(id);
return new OperationResult<string>().Succcedded("Deleted");
}
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.empolyerAgg;
using CompanyManagment.App.Contracts.Representative;
using Company.Domain.InstitutionContractAgg;
using CompanyManagment.EFCore.Repository;
namespace CompanyManagment.Application;
public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository2;
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
private readonly IRepresentativeApplication _representativeApplication;
private readonly IEmployerRepository _employerRepository;
private readonly IInstitutionContractRepository _institutionContractRepository;
@@ -26,7 +28,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public PersonalContractingPartyApplication(
IPersonalContractingPartyRepository personalContractingPartyRepository, IRepresentativeApplication representativeApplication, IEmployerRepository employerRepository, IInstitutionContractRepository institutionContractRepository)
{
_personalContractingPartyRepository2 = personalContractingPartyRepository;
_personalContractingPartyRepository = personalContractingPartyRepository;
_representativeApplication = representativeApplication;
_employerRepository = employerRepository;
_institutionContractRepository = institutionContractRepository;
@@ -36,7 +38,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public OperationResult Create(CreatePersonalContractingParty command)
{
var opration = new OperationResult();
if (_personalContractingPartyRepository2.Exists(x =>
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName ))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
@@ -54,14 +56,14 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
// return opration.Failed("نام خانوادگی وارد شده تکراری است");
//}
if (_personalContractingPartyRepository2.Exists(x => x.Nationalcode == command.Nationalcode && x.LName != command.LName))
if (_personalContractingPartyRepository.Exists(x => x.Nationalcode == command.Nationalcode && x.LName != command.LName))
{
nationalcodeIsOk = false;
return opration.Failed("کد ملی وارد شده تکراری است");
}
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode))
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
return opration.Failed("کد طرف حساب تکراری است");
try
@@ -132,8 +134,8 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
command.State,command.City,command.Zone,command.SureName);
_personalContractingPartyRepository2.Create(personalContractingParty);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.Create(personalContractingParty);
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
@@ -152,13 +154,13 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public OperationResult Edit2(EditPersonalContractingParty command)
{
var opration = new OperationResult();
var personalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
if (personalContractingParty == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
personalContractingParty.Edit2(command.Address);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
@@ -166,7 +168,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
var opration = new OperationResult();
if (_personalContractingPartyRepository2.Exists(x =>
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.LName && x.RegisterId == command.RegisterId && x.SureName == command.SureName))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
@@ -174,23 +176,23 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
if (_personalContractingPartyRepository2.Exists(x => x.LName == command.LName && x.SureName == command.SureName))
if (_personalContractingPartyRepository.Exists(x => x.LName == command.LName && x.SureName == command.SureName))
{
legalNameIsOk = false;
return opration.Failed("نام شرکت وارد شده تکراری است");
}
if (_personalContractingPartyRepository2.Exists(x => x.RegisterId == command.RegisterId && x.LName != command.LName))
if (_personalContractingPartyRepository.Exists(x => x.RegisterId == command.RegisterId && x.LName != command.LName))
{
registerIdIsOk = false;
return opration.Failed("شماره ثبت وارد شده تکراری است");
}
if (_personalContractingPartyRepository2.Exists(x => x.NationalId == command.NationalId && x.LName != command.LName))
if (_personalContractingPartyRepository.Exists(x => x.NationalId == command.NationalId && x.LName != command.LName))
{
nationalIdIsOk = false;
return opration.Failed("شناسه ملی وارد شده تکراری است");
}
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode))
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
return opration.Failed("کد طرف حساب تکراری است");
@@ -204,8 +206,8 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
command.State, command.City, command.Zone,command.SureName);
_personalContractingPartyRepository2.Create(legalContractingParty);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.Create(legalContractingParty);
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
@@ -223,15 +225,15 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
var opration = new OperationResult();
var personalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
if (personalContractingParty == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (command.RepresentativeId < 1)
return opration.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository2.Exists(x =>
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.LName && x.Nationalcode == command.Nationalcode && x.SureName == command.SureName && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
return opration.Failed("کد طرف حساب تکراری است");
try
{
@@ -300,7 +302,7 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
command.State, command.City, command.Zone,command.SureName);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
else
@@ -314,16 +316,16 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
var opration = new OperationResult();
var legalContractingParty = _personalContractingPartyRepository2.Get(command.Id);
var legalContractingParty = _personalContractingPartyRepository.Get(command.Id);
if (legalContractingParty == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (_personalContractingPartyRepository2.Exists(x =>
if (_personalContractingPartyRepository.Exists(x =>
x.LName== command.LName && x.RegisterId == command.RegisterId &&x.SureName == command.SureName &&x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
return opration.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository2.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
return opration.Failed("کد طرف حساب تکراری است");
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
legalContractingParty.EditLegal(command.LName, command.RegisterId,
@@ -331,54 +333,54 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
command.Phone, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName,command.ArchiveCode,
command.State, command.City, command.Zone, command.SureName);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
public EditPersonalContractingParty GetDetails(long id)
{
return _personalContractingPartyRepository2.GetDetails(id);
return _personalContractingPartyRepository.GetDetails(id);
}
public string IsBlockByEmployerId(long employerId)
{
return _personalContractingPartyRepository2.IsBlockByEmployerId(employerId);
return _personalContractingPartyRepository.IsBlockByEmployerId(employerId);
}
public EditPersonalContractingParty GetDetailsToEdit(long id)
{
return _personalContractingPartyRepository2.GetDetailsToEdit(id);
return _personalContractingPartyRepository.GetDetailsToEdit(id);
}
public string GetFullName(long id)
{
return _personalContractingPartyRepository2.GetFullName(id);
return _personalContractingPartyRepository.GetFullName(id);
}
public List<PersonalContractingPartyViewModel> GetPersonalContractingParties()
{
return _personalContractingPartyRepository2.GetPersonalContractingParties();
return _personalContractingPartyRepository.GetPersonalContractingParties();
}
public List<PersonalContractingPartyViewModel> Search(PersonalContractingPartySearchModel searchModel2)
{
return _personalContractingPartyRepository2.Search(searchModel2);
return _personalContractingPartyRepository.Search(searchModel2);
}
public int GetLastArchiveCode()
{
return _personalContractingPartyRepository2.GetLastArchiveCode();
return _personalContractingPartyRepository.GetLastArchiveCode();
}
#region Mahan
public List<string> SearchByName(string name)
{
return _personalContractingPartyRepository2.SearchByName(name);
return _personalContractingPartyRepository.SearchByName(name);
}
#endregion
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
{
return _personalContractingPartyRepository2.GetContractingpartyIdByAccountId(accountId);
return _personalContractingPartyRepository.GetContractingpartyIdByAccountId(accountId);
}
@@ -386,15 +388,15 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
{
return _personalContractingPartyRepository2.GetPersonalContractingPartiesForNationalcode(searchText);
return _personalContractingPartyRepository.GetPersonalContractingPartiesForNationalcode(searchText);
}
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
{
var result= _personalContractingPartyRepository2.SearchForMain(searchModel2);
var result= _personalContractingPartyRepository.SearchForMain(searchModel2);
foreach (var item in result)
{
item.HasInstitutionContract = _personalContractingPartyRepository2.GetHasContract(item.id);
item.HasInstitutionContract = _personalContractingPartyRepository.GetHasContract(item.id);
}
return result;
}
@@ -411,12 +413,12 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
//اونهایی که کارفرما یا قرارداد غیر فعال دارند غیر فعال می شوند
if (_employerRepository.Exists(x => x.ContractingPartyId == id)|| _institutionContractRepository.Exists(x => x.ContractingPartyId == id))
{
opration= _personalContractingPartyRepository2.DeActiveAll(id);
opration= _personalContractingPartyRepository.DeActiveAll(id);
return opration;
}
else
{
opration = _personalContractingPartyRepository2.DeletePersonalContractingParties(id);
opration = _personalContractingPartyRepository.DeletePersonalContractingParties(id);
}
return opration;
@@ -428,10 +430,10 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
var opration = new OperationResult();
var contract = _personalContractingPartyRepository2.Get(id);
var contract = _personalContractingPartyRepository.Get(id);
if (contract == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
return _personalContractingPartyRepository2.ActiveAll(id);
return _personalContractingPartyRepository.ActiveAll(id);
//var opration = new OperationResult();
@@ -446,44 +448,44 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public OperationResult DeActive(long id)
{
var opration = new OperationResult();
var personalContracting = _personalContractingPartyRepository2.Get(id);
var personalContracting = _personalContractingPartyRepository.Get(id);
if (personalContracting == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
personalContracting.DeActive();
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
public bool GetHasContract(long id)
{
return _personalContractingPartyRepository2.GetHasContract(id);
return _personalContractingPartyRepository.GetHasContract(id);
}
public OperationResult Block(long id)
{
var opration = new OperationResult();
var contract = _personalContractingPartyRepository2.Get(id);
var contract = _personalContractingPartyRepository.Get(id);
if (contract == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
contract.Block();
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
public OperationResult DisableBlock(long id)
{
var opration = new OperationResult();
var personalContracting = _personalContractingPartyRepository2.Get(id);
var personalContracting = _personalContractingPartyRepository.Get(id);
if (personalContracting == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
int blockTimes = personalContracting.BlockTimes + 1;
personalContracting.DisableBlock(blockTimes);
_personalContractingPartyRepository2.SaveChanges();
_personalContractingPartyRepository.SaveChanges();
@@ -499,7 +501,225 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
public bool IsBlockCheckByWorkshopId(long workshopId)
{
return _personalContractingPartyRepository2.IsBlockCheckByWorkshopId(workshopId);
return _personalContractingPartyRepository.IsBlockCheckByWorkshopId(workshopId);
}
#endregion
#region Api
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(
ContractingPartyGetListSearchModel searchModel)
{
return await _personalContractingPartyRepository.GetList(searchModel);
}
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
{
return await _personalContractingPartyRepository.GetSelectList();
}
public async Task<OperationResult> CreateReal(CreateRealContractingParty command)
{
var operation = new OperationResult();
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.LName && x.Nationalcode == command.NationalCode && x.SureName == command.SureName))
return operation.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
return operation.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository.Exists(x => x.Nationalcode == command.NationalCode && x.LName != command.LName))
{
nationalcodeIsOk = false;
return operation.Failed("کد ملی وارد شده تکراری است");
}
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
return operation.Failed("کد طرف حساب تکراری است");
if (command.NationalCode.NationalCodeValid() != "valid")
{
return operation.Failed("کد ملی وارد شده نا معتبر است");
}
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
var personalContractingParty = new PersonalContractingParty(command.FName, command.LName,
command.NationalCode, command.IdNumber, "*", "*",
"حقیقی",
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
command.State, command.City, command.Zone, command.SureName);
await _personalContractingPartyRepository.CreateAsync(personalContractingParty);
await _personalContractingPartyRepository.SaveChangesAsync();
return operation.Succcedded();
}
public async Task<OperationResult> CreateLegal(CreateLegalContractingParty command)
{
var opration = new OperationResult();
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.CompanyName && x.RegisterId == command.RegisterId && x.SureName == command.SureName))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
return opration.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.CompanyName && x.SureName == command.SureName))
{
legalNameIsOk = false;
return opration.Failed("نام شرکت وارد شده تکراری است");
}
if (_personalContractingPartyRepository.Exists(x =>
x.RegisterId == command.RegisterId && x.LName != command.CompanyName))
{
registerIdIsOk = false;
return opration.Failed("شماره ثبت وارد شده تکراری است");
}
if (_personalContractingPartyRepository.Exists(x =>
x.NationalId == command.NationalId && x.LName != command.CompanyName))
{
nationalIdIsOk = false;
return opration.Failed("شناسه ملی وارد شده تکراری است");
}
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode))
return opration.Failed("کد طرف حساب تکراری است");
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
var legalContractingParty = new PersonalContractingParty("*", command.CompanyName,
"*", "*", command.RegisterId, command.NationalId,
"حقوقی",
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName,
command.ArchiveCode,
command.State, command.City, command.Zone, command.SureName);
await _personalContractingPartyRepository.CreateAsync(legalContractingParty);
await _personalContractingPartyRepository.SaveChangesAsync();
return opration.Succcedded();
}
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
{
return await _personalContractingPartyRepository.GetNationalCodeOrNationalId();
}
public async Task<OperationResult<string>> Delete(long id)
{
var operationResult = new OperationResult<string>();
try
{
//اگر دارای قرارداد یا دازای کارفرما باشد غیر فعال می شود
if (_employerRepository.Exists(x => x.ContractingPartyId == id) || _institutionContractRepository.Exists(x => x.ContractingPartyId == id))
{
operationResult = await _personalContractingPartyRepository.DeactivateWithSubordinates(id);
return operationResult;
}
var entity = _personalContractingPartyRepository.Get(id);
_personalContractingPartyRepository.Remove(entity);
operationResult.Succcedded("Deleted");
}
catch
{
return operationResult.Failed("خطایی رخ داده است");
}
return operationResult;
}
public OperationResult EditRealApi(EditRealContractingParty command)
{
var opration = new OperationResult();
var personalContractingParty = _personalContractingPartyRepository.Get(command.Id);
if (personalContractingParty == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (command.RepresentativeId < 1)
return opration.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.LName && x.Nationalcode == command.NationalCode && x.SureName == command.SureName && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
return opration.Failed("کد طرف حساب تکراری است");
if (command.NationalCode.NationalCodeValid() != "valid")
{
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
try
{
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
personalContractingParty.Edit(command.FName, command.LName,
command.NationalCode, command.IdNumber,
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
command.State, command.City, command.Zone, command.SureName);
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
catch
{
return opration.Failed("خطایی رخ داده است");
}
}
public OperationResult EditLegal(EditLegalContractingParty command)
{
var opration = new OperationResult();
var legalContractingParty = _personalContractingPartyRepository.Get(command.Id);
if (legalContractingParty == null)
return opration.Failed("رکورد مورد نظر یافت نشد");
if (_personalContractingPartyRepository.Exists(x =>
x.LName == command.CompanyName && x.RegisterId == command.RegisterId && x.SureName == command.SureName && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
if (command.RepresentativeId < 1)
return opration.Failed("لطفا معرف را انتخاب کنید");
if (_personalContractingPartyRepository.Exists(x => x.ArchiveCode == command.ArchiveCode && x.id != command.Id))
return opration.Failed("کد طرف حساب تکراری است");
var representative = _representativeApplication.GetDetails(command.RepresentativeId);
legalContractingParty.EditLegal(command.CompanyName, command.RegisterId,
command.NationalId,
command.PhoneNumber, command.AgentPhone, command.Address, command.RepresentativeId, representative.FullName, command.ArchiveCode,
command.State, command.City, command.Zone, command.SureName);
_personalContractingPartyRepository.SaveChanges();
return opration.Succcedded();
}
public async Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id)
{
return await _personalContractingPartyRepository.GetRealDetails(id);
}
public async Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id)
{
return await _personalContractingPartyRepository.GetLegalDetails(id);
}
#endregion

View File

@@ -17,204 +17,206 @@ namespace CompanyManagment.Application;
public class RollCallEmployeeApplication : IRollCallEmployeeApplication
{
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IEmployeeRepository _employeeRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IWebHostEnvironment _webHostEnvironment;
public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment)
{
_rollCallEmployeeRepository = rollCallEmployeeRepository;
_employeeRepository = employeeRepository;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_leftWorkRepository = leftWorkRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_webHostEnvironment = webHostEnvironment;
}
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IEmployeeRepository _employeeRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IWebHostEnvironment _webHostEnvironment;
public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment)
{
_rollCallEmployeeRepository = rollCallEmployeeRepository;
_employeeRepository = employeeRepository;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_leftWorkRepository = leftWorkRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_webHostEnvironment = webHostEnvironment;
}
public OperationResult Create(CreateRollCallEmployee command)
{
var opreation = new OperationResult();
public OperationResult Create(CreateRollCallEmployee command)
{
var opreation = new OperationResult();
if (_rollCallEmployeeRepository.Exists(x =>
x.EmployeeId == command.EmployeeId && x.WorkshopId == command.EmployeeId))
return opreation.Succcedded();
var fullname = _employeeRepository.GetDetails(command.EmployeeId);
if (fullname == null)
return opreation.Failed("پرسنل یافت نشد");
if (_rollCallEmployeeRepository.Exists(x =>
x.EmployeeId == command.EmployeeId && x.WorkshopId == command.EmployeeId))
return opreation.Succcedded();
var fullname = _employeeRepository.GetDetails(command.EmployeeId);
if (fullname == null)
return opreation.Failed("پرسنل یافت نشد");
var create = new RollCallEmployee(command.WorkshopId, command.EmployeeId, fullname.FName, fullname.LName);
_rollCallEmployeeRepository.Create(create);
if (command.HasUploadedImage == "true")
create.HasImage();
if (command.HasUploadedImage == "true")
create.HasImage();
_rollCallEmployeeRepository.SaveChanges();
return opreation.Succcedded(create.id);
_rollCallEmployeeRepository.SaveChanges();
return opreation.Succcedded(create.id);
}
}
public OperationResult Active(long id)
{
var opreation = new OperationResult();
public OperationResult Active(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.Get(id);
var emp = _rollCallEmployeeRepository.Get(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
if (!_leftWorkRepository.Exists(x => x.EmployeeId == emp.EmployeeId && x.WorkshopId == emp.WorkshopId &&
x.StartWorkDate <= DateTime.Now && x.LeftWorkDate > DateTime.Now))
return opreation.Failed("کارمند شروع به کار ندارد");
if (!_leftWorkRepository.Exists(x => x.EmployeeId == emp.EmployeeId && x.WorkshopId == emp.WorkshopId &&
x.StartWorkDate <= DateTime.Now && x.LeftWorkDate > DateTime.Now))
return opreation.Failed("کارمند شروع به کار ندارد");
if (emp.HasUploadedImage == "false")
return opreation.Failed("لطفا ابتدا عکس پرسنل را آپلود کنید");
if (emp.HasUploadedImage == "false")
return opreation.Failed("لطفا ابتدا عکس پرسنل را آپلود کنید");
using var transaction = new TransactionScope();
using var transaction = new TransactionScope();
emp.Active();
var operation2 = _rollCallEmployeeStatusApplication.Create(new CreateRollCallEmployeeStatus() { RollCallEmployeeId = id });
if (operation2.IsSuccedded == false)
return operation2;
var operation2 = _rollCallEmployeeStatusApplication.Create(new CreateRollCallEmployeeStatus() { RollCallEmployeeId = id });
if (operation2.IsSuccedded == false)
return operation2;
_rollCallEmployeeRepository.SaveChanges();
transaction.Complete();
return operation2;
}
}
public OperationResult DeActive(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetWithRollCallStatus(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var lastStatus = emp.EmployeesStatus.MaxBy(x => x.StartDate);
emp.DeActive();
_rollCallEmployeeRepository.SaveChanges();
_rollCallEmployeeStatusApplication.Deactivate(lastStatus.id);
return opreation.Succcedded();
}
public OperationResult DeActive(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetWithRollCallStatus(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var lastStatus = emp.EmployeesStatus.MaxBy(x => x.StartDate);
emp.DeActive();
_rollCallEmployeeRepository.SaveChanges();
_rollCallEmployeeStatusApplication.Deactivate(lastStatus.id);
return opreation.Succcedded();
}
public OperationResult UploadedImage(long Employeeid, long WorkshopId)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(Employeeid, WorkshopId);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
public OperationResult UploadedImage(long Employeeid, long WorkshopId)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(Employeeid, WorkshopId);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var rollCall = _rollCallEmployeeRepository.Get(emp.Id);
rollCall.HasImage();
_rollCallEmployeeRepository.SaveChanges();
var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", WorkshopId.ToString(), Employeeid.ToString());
var thumbnailPath = Path.Combine(path, "Thumbnail.jpg");
try
{
var thumbnail = Tools.ResizeImage(Path.Combine(path, "1.jpg"), 150, 150);
System.IO.File.WriteAllBytes(thumbnailPath, Convert.FromBase64String(thumbnail));
}
catch
{
// ignored
}
var rollCall = _rollCallEmployeeRepository.Get(emp.Id);
rollCall.HasImage();
_rollCallEmployeeRepository.SaveChanges();
var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", WorkshopId.ToString(), Employeeid.ToString());
var thumbnailPath = Path.Combine(path, "Thumbnail.jpg");
try
{
var thumbnail = Tools.ResizeImage(Path.Combine(path, "1.jpg"), 150, 150);
System.IO.File.WriteAllBytes(thumbnailPath, Convert.FromBase64String(thumbnail));
}
catch
{
// ignored
}
return opreation.Succcedded();
}
return opreation.Succcedded();
}
public List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetByWorkshopId(workshopId);
}
public EditRollCallEmployee GetDetails(long id)
{
return _rollCallEmployeeRepository.GetDetails(id);
}
public EditRollCallEmployee GetDetails(long id)
{
return _rollCallEmployeeRepository.GetDetails(id);
}
public RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId)
{
return _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
}
public RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId)
{
return _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListPaginate(RollCallEmployeeSearchModel command)
{
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListPaginate(RollCallEmployeeSearchModel command)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListPaginate(command);
}
public int activedPerson(long workshopId)
{
return _rollCallEmployeeRepository.activedPerson(workshopId);
}
public int activedPerson(long workshopId)
{
return _rollCallEmployeeRepository.activedPerson(workshopId);
}
#region Pooya
public List<RollCallEmployeeViewModel> GetRollCallEmployeesByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetRollCallEmployeesByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetActivePersonnelByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
}
#region Pooya
public List<RollCallEmployeeViewModel> GetRollCallEmployeesByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetRollCallEmployeesByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetActivePersonnelByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
}
public bool IsEmployeeRollCallActive(long employeeId, long workshopId)
{
RollCallEmployeeViewModel rollCallEmployee = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
if (rollCallEmployee == null || rollCallEmployee.IsActiveString != "true" || rollCallEmployee.HasUploadedImage != "true")
return false;
var now = DateTime.Now;
return _rollCallEmployeeStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id && x.StartDate < now && x.EndDate > now);
}
public List<RollCallEmployeeViewModel> GetEmployeeRollCalls(long workshopId)
{
return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId);
}
public (int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId)
{
return _rollCallEmployeeRepository.GetActiveAndDeActiveRollCallEmployees(workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListAll(long workshopId)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListAll(workshopId);
}
public bool HasEmployees(long workshopId)
{
return _rollCallEmployeeRepository.HasEmployees(workshopId);
}
public OperationResult ChangeEmployeeRollCallName(long rollCallEmployeeId, string fName, string lName)
{
OperationResult result = new();
if (string.IsNullOrWhiteSpace(lName) || string.IsNullOrWhiteSpace(fName))
return result.Failed("نام و نام خانوادگی نمی توانند خالی باشند");
fName = fName.Trim();
lName = lName.Trim();
var fullName = $"{fName} {lName}";
var entity = _rollCallEmployeeRepository.Get(rollCallEmployeeId);
public bool IsEmployeeRollCallActive(long employeeId, long workshopId)
{
RollCallEmployeeViewModel rollCallEmployee = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
if (rollCallEmployee == null || rollCallEmployee.IsActiveString != "true" || rollCallEmployee.HasUploadedImage != "true")
return false;
var now = DateTime.Now;
return _rollCallEmployeeStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id && x.StartDate < now && x.EndDate > now);
if (entity == null)
return result.Failed(ApplicationMessages.RecordNotFound);
if (_rollCallEmployeeRepository.Exists(x => x.WorkshopId == entity.WorkshopId && x.EmployeeFullName == fullName && x.id != rollCallEmployeeId))
return result.Failed("نام و نام خانوادگی کارمند نمی تواند با نام و نام خانوادگی کارمند دیگری در آن کارگاه یکسان باشد");
}
if (entity.IsActiveString != "true")
return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد");
public List<RollCallEmployeeViewModel> GetEmployeeRollCalls(long workshopId)
{
return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId);
}
public (int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId)
{
return _rollCallEmployeeRepository.GetActiveAndDeActiveRollCallEmployees(workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListAll(long workshopId)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListAll(workshopId);
}
public bool HasEmployees(long workshopId)
{
return _rollCallEmployeeRepository.HasEmployees(workshopId);
}
public OperationResult ChangeEmployeeRollCallName(long rollCallEmployeeId, string fName, string lName)
{
OperationResult result = new();
if (string.IsNullOrWhiteSpace(lName) || string.IsNullOrWhiteSpace(fName))
return result.Failed("نام و نام خانوادگی نمی توانند خالی باشند");
fName = fName.Trim();
lName = lName.Trim();
var fullName = $"{fName} {lName}";
var entity = _rollCallEmployeeRepository.Get(rollCallEmployeeId);
entity.ChangeName(fName, lName);
_rollCallEmployeeRepository.SaveChanges();
return result.Succcedded();
}
if (entity == null)
return result.Failed(ApplicationMessages.RecordNotFound);
if (_rollCallEmployeeRepository.Exists(x => x.WorkshopId == entity.WorkshopId && x.EmployeeFullName == fullName && x.id != rollCallEmployeeId))
return result.Failed("نام و نام خانوادگی کارمند نمی تواند با نام و نام خانوادگی کارمند دیگری در آن کارگاه یکسان باشد");
if (entity.IsActiveString != "true")
return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد");
entity.ChangeName(fName, lName);
_rollCallEmployeeRepository.SaveChanges();
return result.Succcedded();
}
#endregion
}

View File

@@ -89,60 +89,9 @@ namespace CompanyManagment.Application
}
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
//موقت
// دادمهرگستر 11 *
//585 کاشی گالری سرامیس (بابک ابراهیمی )
//آموزشگاه ملل 604 *
//کاریابی ملل 605 *
//368 پیتزا امیر آماده سازی
//367 پیتزا امیر رستوران
//286 مرکز توان بخشی رسالت *
//610 بیمارستان پارس - رازقی طعام
DateTime start1404 = new DateTime(2025, 03, 21);
bool skipRollCallByWorkshopId = false;
if (contractStart < start1404)
{
skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367 or 286;
}
else
{
skipRollCallByWorkshopId = workshopId is 368 or 367 or 585 or 610;
}
//#if DEBUG
// skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367;
//#endif
if (skipRollCallByWorkshopId)
return false;
// 42550 مصطفی مقدس نژاد فومنی
bool skipRollCallByEmployeeId = employeeId is 42550;
if (skipRollCallByEmployeeId)
return false;
//9211 محسا تازه
if (employeeId == 9211 && contractStart >= start1404)
return false;
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
if (!service.Any(x => x.StartService.Date <= contractStart.Date && x.EndService.Date >= contractEnd.Date))
return false;
var rollCallEmployee =
_rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
if (rollCallEmployee == null)
return false;
return _employeeRollCallStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id &&
x.StartDate.Date <= contractStart.Date &&
x.EndDate.Date >= contractEnd.Date);
}
{
return _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd);
}
public List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr)
{
@@ -185,5 +134,38 @@ namespace CompanyManagment.Application
{
return _employeeRollCallStatusRepository.GetAll();
}
}
public void SyncRollCallEmployeeWithLeftWork(long rollCallEmployeeId)
{
var rollCallEmployee = _rollCallEmployeeRepository.GetWithRollCallStatus(rollCallEmployeeId);
if (rollCallEmployee == null)
return;
var rollCallStatus = rollCallEmployee.EmployeesStatus.MaxBy(x => x.StartDate);
if (rollCallStatus == null)
return;
var today = DateTime.Today;
var firstDayOfMonth = today.FindFirstDayOfMonthGr();
var employeeId = rollCallEmployee.EmployeeId;
var workshopId = rollCallEmployee.WorkshopId;
var leftWork = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employeeId);
if (leftWork == null)
return;
var startWork = leftWork.StartWorkDate;
rollCallStatus.Edit(startWork < firstDayOfMonth ? firstDayOfMonth : startWork, rollCallStatus.EndDate);
_employeeRollCallStatusRepository.SaveChanges();
}
}
}

View File

@@ -13,5 +13,32 @@ public class InsuranceListMapping : IEntityTypeConfiguration<InsuranceList>
builder.Property(x => x.Year).HasMaxLength(4);
builder.Property(x => x.Month).HasMaxLength(2);
builder.ComplexProperty(x => x.Inspection, inspection =>
{
inspection.IsRequired();
inspection.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
inspection.Property(x => x.LastInspectionDateTime);
inspection.Property(x => x.MediaId);
});
builder.ComplexProperty(x => x.Debt, debt =>
{
debt.IsRequired();
debt.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
debt.Property(x => x.DebtDate);
debt.Property(x => x.Amount);
debt.Property(x => x.MediaId);
});
builder.ComplexProperty(x => x.EmployerApproval, approval =>
{
approval.IsRequired();
approval.Property(x => x.Status).HasConversion<string>().HasMaxLength(50);
approval.Property(x => x.Description).HasMaxLength(500);
});
//builder.HasMany(x => x.EmployerSignatures)
// .WithOne(x => x.InsuranceList).HasForeignKey(x => x.InsuranceListId);
}
}

View File

@@ -0,0 +1,121 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addinspectiondebtapprovaltoinsurancelist : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "Debt_Amount",
table: "InsuranceLists",
type: "float",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<DateTime>(
name: "Debt_DebtDate",
table: "InsuranceLists",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<long>(
name: "Debt_MediaId",
table: "InsuranceLists",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<string>(
name: "Debt_Type",
table: "InsuranceLists",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "None");
migrationBuilder.AddColumn<string>(
name: "EmployerApproval_Description",
table: "InsuranceLists",
type: "nvarchar(500)",
maxLength: 500,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "EmployerApproval_Status",
table: "InsuranceLists",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "None");
migrationBuilder.AddColumn<DateTime>(
name: "Inspection_LastInspectionDateTime",
table: "InsuranceLists",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<long>(
name: "Inspection_MediaId",
table: "InsuranceLists",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<string>(
name: "Inspection_Type",
table: "InsuranceLists",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "None");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Debt_Amount",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Debt_DebtDate",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Debt_MediaId",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Debt_Type",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "EmployerApproval_Description",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "EmployerApproval_Status",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Inspection_LastInspectionDateTime",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Inspection_MediaId",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Inspection_Type",
table: "InsuranceLists");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class insuranceoperationlist : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "Debt_IsDone",
table: "InsuranceLists",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "EmployerApproval_IsDone",
table: "InsuranceLists",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "Inspection_IsDone",
table: "InsuranceLists",
type: "bit",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Debt_IsDone",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "EmployerApproval_IsDone",
table: "InsuranceLists");
migrationBuilder.DropColumn(
name: "Inspection_IsDone",
table: "InsuranceLists");
}
}
}

View File

@@ -1,5 +1,6 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using CompanyManagment.EFCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -3394,6 +3395,64 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.ComplexProperty<Dictionary<string, object>>("Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
{
b1.IsRequired();
b1.Property<double>("Amount")
.HasColumnType("float");
b1.Property<DateTime>("DebtDate")
.HasColumnType("datetime2");
b1.Property<bool>("IsDone")
.HasColumnType("bit");
b1.Property<long>("MediaId")
.HasColumnType("bigint");
b1.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
});
b.ComplexProperty<Dictionary<string, object>>("EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
{
b1.IsRequired();
b1.Property<string>("Description")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b1.Property<bool>("IsDone")
.HasColumnType("bit");
b1.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
});
b.ComplexProperty<Dictionary<string, object>>("Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
{
b1.IsRequired();
b1.Property<bool>("IsDone")
.HasColumnType("bit");
b1.Property<DateTime>("LastInspectionDateTime")
.HasColumnType("datetime2");
b1.Property<long>("MediaId")
.HasColumnType("bigint");
b1.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
});
b.HasKey("id");
b.ToTable("InsuranceLists", (string)null);

View File

@@ -10,265 +10,340 @@ using AccountMangement.Infrastructure.EFCore;
using Company.Domain.AdminMonthlyOverviewAgg;
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.EntityFrameworkCore;
using Tools = _0_Framework_b.Application.Tools;
namespace CompanyManagment.EFCore.Repository;
public class AdminMonthlyOverviewRepository : RepositoryBase<long, AdminMonthlyOverview>, IAdminMonthlyOverviewRepository
{
private readonly CompanyContext _companyContext;
private readonly AccountContext _accountContext;
public AdminMonthlyOverviewRepository(CompanyContext companyContext, AccountContext accountContext) : base(companyContext)
{
_companyContext = companyContext;
_accountContext = accountContext;
}
private readonly CompanyContext _companyContext;
private readonly AccountContext _accountContext;
public AdminMonthlyOverviewRepository(CompanyContext companyContext, AccountContext accountContext) : base(companyContext)
{
_companyContext = companyContext;
_accountContext = accountContext;
}
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel)
{
var year = searchModel.Year;
var month = searchModel.Month;
var accountId = searchModel.AdminAccountId;
// اگر تبدیل تاریخ به میلادی موفق نبود، لیست خالی برگردان
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var targetDate) == false)
return [];
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel)
{
// دریافت اطلاعات ادمین
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
// اگر ادمین پیدا نشد، لیست خالی برگردان
if (adminAccount == null)
return [];
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
var contractingPartyIds = _companyContext.InstitutionContractSet.AsNoTracking()
.Where(c => c.ContractStartGr <= targetDate && c.ContractEndGr >= targetDate && c.IsActiveString == "true")
.Select(c => c.ContractingPartyId);
// دریافت کارگاه‌های مرتبط با اکانت
var accountWorkshopIds = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId);
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// Replace the selected code with the following to return a list of anonymous objects containing both workshop and contractingParty
var year = searchModel.Year;
var month = searchModel.Month;
var accountId = searchModel.AdminAccountId;
// اگر تبدیل تاریخ به میلادی موفق نبود، لیست خالی برگردان
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var targetStartDate) == false)
return [];
var targetEndDate = Tools.FindeEndOfMonth(targetStartDate.ToFarsi()).ToGeorgianDateTime();
var workshopsWithContractingParty =await _companyContext.Workshops
.AsNoTracking()
.Where(w => accountWorkshopIds.Contains(w.id))
.Include(w => w.WorkshopEmployers)
.ThenInclude(we => we.Employer)
.ThenInclude(e => e.ContractingParty).AsSplitQuery().
Where(w => w.WorkshopEmployers.Any(we =>
we.Employer != null &&
contractingPartyIds.Contains(we.Employer.ContractingPartyId)))
.Select(w => new
{
Workshop = w,
ContractingParty = w.WorkshopEmployers
.Where(we => we.Employer != null && contractingPartyIds.Contains(we.Employer.ContractingPartyId))
.Select(we => we.Employer.ContractingParty)
.FirstOrDefault()
})
.ToListAsync();
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextFirstMonth);
var nextEndMonth = Tools.FindeEndOfMonth(nextFirstMonth.ToFarsi()).ToGeorgianDateTime();
var workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
// پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
.Select(x => x.WorkshopId)
.ToListAsync();
// دریافت اطلاعات ادمین
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
// اگر ادمین پیدا نشد، لیست خالی برگردان
if (adminAccount == null)
return [];
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
var contractingPartyIds = _companyContext.InstitutionContractSet.AsNoTracking()
.Where(c => c.ContractStartGr <= targetEndDate && c.ContractEndGr >= targetStartDate)
.Select(c => c.ContractingPartyId);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds);
// دریافت کارگاه‌های مرتبط با اکانت
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "true" : "false";
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
}
// دریافت همه AdminMonthlyOverview برای این کارگاه‌ها/ماه/سال
var adminMonthlyOverviewsQuery = _companyContext.AdminMonthlyOverviews
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year);
if (searchModel.WorkshopId > 0)
{
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => x.WorkshopId == searchModel.WorkshopId);
}
if (searchModel.EmployerId > 0)
{
var searchWorkshopId = workshopsWithContractingParty.Where(x => x.Workshop.WorkshopEmployers.Any(e => e.EmployerId == searchModel.EmployerId)).Select(x => x.Workshop.id).ToList();
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => searchWorkshopId.Contains(x.WorkshopId));
}
var workshopAccounts = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId).ToList();
var adminMonthlyOverviewsList = await adminMonthlyOverviewsQuery.ToListAsync();
var employeeCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate < targetDate && x.LeftWorkDate > targetDate && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var adminMonthlyOverviewList = adminMonthlyOverviewsList.Select(x =>
{
var employeeCount = employeeCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var workshopWithContractingParty =
workshopsWithContractingParty.FirstOrDefault(w => w.Workshop.id == x.WorkshopId);
var workshop = workshopWithContractingParty?.Workshop;
var contractingParty = workshopWithContractingParty?.ContractingParty;
var employer = workshop?.WorkshopEmployers.FirstOrDefault()?.Employer;
return new AdminMonthlyOverviewListViewModel
{
WorkshopId = x.WorkshopId,
Status = x.Status,
Id = x.id,
WorkshopName = workshop?.WorkshopFullName ?? "",
WorkshopArchiveCode = workshop?.ArchiveCode ?? "",
Address = workshop?.Address ?? "",
City = workshop?.City ?? "",
Province = workshop?.State ?? "",
EmployerName = employer?.FullName ?? "",
EmployerPhoneNumber = employer?.Phone ?? "",
AdminFullName = adminAccount.Fullname,
EmployeeCount = employeeCount?.EmployeeCounts ?? 0,
AgentPhoneNumber = "",
IsBlock = contractingParty?.IsBlock == "true"
};
}).OrderBy(x => x.IsBlock).ToList();
return adminMonthlyOverviewList;
}
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
{
var searchModel = new AdminMonthlyOverviewSearchModel()
{
AdminAccountId = accountId,
Month = month,
Year = year
};
var list = await GetWorkshopStatus(searchModel);
var allCount = list.Count;
var archivedCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.Archived);
var createDocCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.CreateDocuments);
var visitCompleteCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitCompleted);
var visitInProgressCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitInProgress);
var visitPendingCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitPending);
return new AdminMonthlyOverViewCounterVm
{
All = allCount,
Archived = archivedCount,
VisitPending = visitPendingCount,
VisitInProgress = visitInProgressCount,
VisitCompleted = visitCompleteCount,
CreateDocument = createDocCount
};
}
private async Task UpdateAdminMonthlyOverviewStatus(int year, int month, List<long> workshopIds)
{
var targetDate = $"{year:0000}/{month:00}/01".ToGeorgianDateTime();
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextMonth);
var workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x =>
((x.StartWorkDate <= targetEndDate && x.LeftWorkDate.AddDays(-1) >= targetStartDate)
|| (x.StartWorkDate <= nextEndMonth && x.LeftWorkDate.AddDays(-1) >= nextFirstMonth)) && workshopAccounts.Contains(x.WorkshopId)).Select(x => x.WorkshopId);
var workingEmployeeIds = (await _companyContext.LeftWorkList.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkDate <= targetDate && x.LeftWorkDate >= targetDate)
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync()).Distinct();
var contractSet = (await _companyContext.Contracts.AsNoTracking()
.Where(x => x.ContarctStart <= nextMonth && x.ContractEnd >= nextMonth)
.Select(x => new { x.WorkshopIds, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopIds, x.EmployeeId))
.ToHashSet();
var checkoutSet = (await _companyContext.CheckoutSet.AsNoTracking()
.Where(x => x.ContractStart <= targetDate && x.ContractEnd >= targetDate)
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopId, x.EmployeeId))
.ToHashSet();
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// Replace the selected code with the following to return a list of anonymous objects containing both workshop and contractingParty
var workshopsWithContractingParty = await _companyContext.Workshops
.AsNoTracking()
.Where(w => workshopsHasLeftWorkEmployees.Contains(w.id) && w.IsActive)
.Include(w => w.WorkshopEmployers)
.ThenInclude(we => we.Employer)
.ThenInclude(e => e.ContractingParty).AsSplitQuery().
Where(w => w.WorkshopEmployers.Any(we =>
we.Employer != null &&
contractingPartyIds.Contains(we.Employer.ContractingPartyId)))
.Select(w => new
{
Workshop = w,
ContractingParty = w.WorkshopEmployers
.Where(we => we.Employer != null && contractingPartyIds.Contains(we.Employer.ContractingPartyId))
.Select(we => we.Employer.ContractingParty)
.FirstOrDefault()
})
.ToListAsync();
var grouped = workingEmployeeIds.GroupBy(x => x.WorkshopId).ToList();
var workshopsWithFullContracts = grouped
.Where(g => g.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
var workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
var workshopsWithFullCheckout = grouped
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
var fullyCoveredWorkshops = workshopsWithFullContracts.Intersect(workshopsWithFullCheckout).ToList();
// پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
.Select(x => x.WorkshopId)
.ToListAsync();
var notFullyCoveredWorkshops = grouped
.Where(g => g.Any(emp =>
!contractSet.Contains((emp.WorkshopId, emp.EmployeeId)) ||
!checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
.Where(x => x.Month == month && x.Year == year);
var adminMonthlyOverviewsWithFullContracts = await adminMonthlyOverviews
.Where(x => fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status == AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
var adminMonthlyOverviewsWithNotFullContracts = await adminMonthlyOverviews
.Where(x => notFullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status != AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds, targetStartDate,targetEndDate, nextFirstMonth,nextEndMonth);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "false" : "true";
await _companyContext.SaveChangesAsync();
}
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
private async Task CreateRangeAdminMonthlyOverview(List<long> workshopIds, int month, int year)
{
foreach (var workshopId in workshopIds)
{
var adminMonthlyOverview =
new AdminMonthlyOverview(workshopId, month, year, AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.AddAsync(adminMonthlyOverview);
}
workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
}
await _companyContext.SaveChangesAsync();
}
// دریافت همه AdminMonthlyOverview برای این کارگاه‌ها/ماه/سال
var adminMonthlyOverviewsQuery = _companyContext.AdminMonthlyOverviews
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year);
if (searchModel.WorkshopId > 0)
{
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => x.WorkshopId == searchModel.WorkshopId);
}
if (searchModel.EmployerId > 0)
{
var searchWorkshopId = workshopsWithContractingParty.Where(x => x.Workshop.WorkshopEmployers.Any(e => e.EmployerId == searchModel.EmployerId)).Select(x => x.Workshop.id).ToList();
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => searchWorkshopId.Contains(x.WorkshopId));
}
var employeeCheckoutCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= targetStartDate && x.LeftWorkDate.AddDays(-1) >= targetStartDate && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var employeeContractCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= nextFirstMonth && x.LeftWorkDate.AddDays(-1) >= nextFirstMonth && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var adminMonthlyOverviewsList = await adminMonthlyOverviewsQuery.ToListAsync();
var now = DateTime.Today;
//پرسنل ادمین اجرایی
var operatorAdminAccounts = _accountContext.AccountLeftWorks
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkGr <= now && x.LeftWorkGr >= now &&
x.RoleId == 5).Select(x => new { x.WorkshopId, x.AccountId })
.Join(_accountContext.Accounts,
x => x.AccountId,
account => account.id, (x, account) => new
{
x.WorkshopId,
account.Fullname
}).ToList();
var adminMonthlyOverviewList = adminMonthlyOverviewsList.Select(x =>
{
var employeeCheckoutCount = employeeCheckoutCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var employeeContractCount = employeeContractCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var workshopWithContractingParty =
workshopsWithContractingParty.FirstOrDefault(w => w.Workshop.id == x.WorkshopId);
var operatorAccount = operatorAdminAccounts.FirstOrDefault(o => o.WorkshopId == x.WorkshopId);
var workshop = workshopWithContractingParty?.Workshop;
var contractingParty = workshopWithContractingParty?.ContractingParty;
var employer = workshop?.WorkshopEmployers.FirstOrDefault()?.Employer;
return new AdminMonthlyOverviewListViewModel
{
WorkshopId = x.WorkshopId,
Status = x.Status,
Id = x.id,
WorkshopName = workshop?.WorkshopFullName ?? "",
WorkshopArchiveCode = workshop?.ArchiveCode ?? "",
WorkshopArchiveCodeInt = workshop?.ArchiveCode.ExtractIntNumbers() ?? 0,
Address = workshop?.Address ?? "",
City = workshop?.City ?? "",
Province = workshop?.State ?? "",
EmployerName = employer?.FullName ?? "",
EmployerPhoneNumber = employer?.Phone ?? "",
AdminFullName = operatorAccount?.Fullname ?? "",
CheckoutEmployeeCount = employeeCheckoutCount?.EmployeeCounts ?? 0,
ContractEmployeeCount = employeeContractCount?.EmployeeCounts ?? 0,
AgentPhoneNumber = "",
IsBlock = contractingParty?.IsBlock == "true"
};
}).OrderBy(x => x.IsBlock).ThenBy(x => x.WorkshopArchiveCodeInt).ToList();
return adminMonthlyOverviewList;
}
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
{
var searchModel = new AdminMonthlyOverviewSearchModel()
{
AdminAccountId = accountId,
Month = month,
Year = year
};
var list = await GetWorkshopStatus(searchModel);
var allCount = list.Count;
var archivedCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.Archived);
var createDocCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.CreateDocuments);
var visitCompleteCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitCompleted);
var visitInProgressCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitInProgress);
var visitPendingCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitPending);
return new AdminMonthlyOverViewCounterVm
{
All = allCount,
Archived = archivedCount,
VisitPending = visitPendingCount,
VisitInProgress = visitInProgressCount,
VisitCompleted = visitCompleteCount,
CreateDocument = createDocCount
};
}
private async Task UpdateAdminMonthlyOverviewStatus(int year, int month, List<long> workshopIds, DateTime targetStartDate,DateTime targetEndDate, DateTime nextStartMonth,DateTime nextEndMonth)
{
var vipGroup = _companyContext.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
var workingCheckoutEmployeeIds = _companyContext.LeftWorkList.AsNoTracking()
.Join(
_companyContext.Contracts.AsNoTracking(),
leftWork => new { leftWork.EmployeeId, WorkshopId = leftWork.WorkshopId },
contract => new { contract.EmployeeId, WorkshopId = contract.WorkshopIds },
(leftWork, contract) => new { leftWork, contract }
)
.Where(x =>
workshopIds.Contains(x.leftWork.WorkshopId) &&
x.leftWork.StartWorkDate <= targetEndDate &&
x.leftWork.LeftWorkDate.AddDays(-1) >= targetStartDate &&
x.contract.ContarctStart <= targetEndDate &&
x.contract.ContractEnd >= targetStartDate &&
!vipGroup.Contains(x.leftWork.EmployeeId) &&
!_companyContext.EmployeeClientTemps
.Any(temp => temp.EmployeeId == x.leftWork.EmployeeId && temp.WorkshopId == x.leftWork.WorkshopId)
)
.Select(x => new { x.leftWork.WorkshopId, x.leftWork.EmployeeId });
var workingContractEmployeeIds = _companyContext.LeftWorkList.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkDate <= nextEndMonth && x.LeftWorkDate.AddDays(-1) >= nextStartMonth &&
!vipGroup.Contains(x.EmployeeId) &&
!_companyContext.EmployeeClientTemps
.Any(temp => temp.EmployeeId == x.EmployeeId && temp.WorkshopId == x.WorkshopId)
).Select(x => new { x.WorkshopId, x.EmployeeId });
var contractSet = (await _companyContext.Contracts.AsNoTracking()
.Where(x => x.ContarctStart <= nextEndMonth && x.ContractEnd >= nextStartMonth && workshopIds.Contains(x.WorkshopIds))
.Select(x => new { x.WorkshopIds, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopIds, x.EmployeeId))
.ToHashSet();
var checkoutSet = (await _companyContext.CheckoutSet.AsNoTracking()
.Where(x => x.ContractStart <= targetEndDate && x.ContractEnd >= targetStartDate && workshopIds.Contains(x.WorkshopId))
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopId, x.EmployeeId))
.ToHashSet();
var workingCheckoutGrouping = workingCheckoutEmployeeIds.GroupBy(x => x.WorkshopId).ToList();
var workingContractGrouping = workingContractEmployeeIds.GroupBy(x => x.WorkshopId).Select(x => new
{
WorkshopId = x.Key,
Data = x.ToList()
}).ToList();
var workshopsWithFullContracts = workingContractGrouping
.Where(g => g.Data.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.WorkshopId)
.ToList();
var list = workingContractEmployeeIds.ToList().Where(x=>!contractSet.Any(a=>a.EmployeeId== x.EmployeeId&&a.WorkshopIds == x.WorkshopId)).ToList();
var workshopsWithFullCheckout = workingCheckoutGrouping
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
var fullyCoveredWorkshops = workshopsWithFullContracts.Intersect(workshopsWithFullCheckout).ToList();
//var notFullyCoveredWorkshops = groupedCheckout
// .Where(g => g.Any(emp =>
// !contractSet.Contains((emp.WorkshopId, emp.EmployeeId)) ||
// !checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
// .Select(g => g.Key)
// .ToList();
var notFullyCoveredWorkshops = workshopIds.Except(fullyCoveredWorkshops);
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
.Where(x => x.Month == month && x.Year == year);
var adminMonthlyOverviewsWithFullContracts = await adminMonthlyOverviews
.Where(x => fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status == AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
var adminMonthlyOverviewsWithNotFullContracts = await adminMonthlyOverviews
.Where(x => notFullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status != AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.SaveChangesAsync();
}
private async Task CreateRangeAdminMonthlyOverview(List<long> workshopIds, int month, int year)
{
foreach (var workshopId in workshopIds)
{
var adminMonthlyOverview =
new AdminMonthlyOverview(workshopId, month, year, AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.AddAsync(adminMonthlyOverview);
}
await _companyContext.SaveChangesAsync();
}
}

View File

@@ -1,18 +1,22 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.CheckoutAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.RollCallAgg;
using Company.Domain.RollCallEmployeeAgg;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.HolidayItem;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.Leave;
using CompanyManagment.App.Contracts.LeftWork;
using CompanyManagment.App.Contracts.Loan;
@@ -21,6 +25,7 @@ using CompanyManagment.App.Contracts.SalaryAid;
using CompanyManagment.App.Contracts.WorkingHours;
using CompanyManagment.App.Contracts.WorkingHoursTemp;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.EFCore.Migrations;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -41,8 +46,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallRepository _rollCallRepository;
private readonly IRollCallMandatoryRepository _rollCallMandatoryRepository;
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
public CheckoutRepository(IAuthHelper authHelper, CompanyContext context, IConfiguration configuration, ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication, IRollCallRepository rollCallRepository, IRollCallMandatoryRepository rollCallMandatoryRepository) : base(context)
public CheckoutRepository(IAuthHelper authHelper, CompanyContext context, IConfiguration configuration, ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication, IRollCallRepository rollCallRepository, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallEmployeeRepository rollCallEmployeeRepository) : base(context)
{
_authHelper = authHelper;
@@ -52,6 +58,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
_workingHoursTempApplication = workingHoursTempApplication;
_rollCallRepository = rollCallRepository;
_rollCallMandatoryRepository = rollCallMandatoryRepository;
_rollCallEmployeeRepository = rollCallEmployeeRepository;
}
/// <summary>
@@ -123,6 +130,361 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
.FirstOrDefault(x => x.Id == id);
}
/// <summary>
/// لود لیست اولیه جهت ایجاد فیش حقوقی
/// </summary>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId, string year, string month, string contractStart,
string contractEnd)
{
DateTime startSreach;
DateTime endSearch;
if (!string.IsNullOrWhiteSpace(contractStart) && !string.IsNullOrWhiteSpace(contractEnd))
{
startSreach = contractStart.ToGeorgianDateTime();
endSearch = contractEnd.ToGeorgianDateTime();
}
else
{
if (month == "0" && year == "0")
{
DateTime now = DateTime.Now;
string startStr = $"{now.ToFarsi().Substring(0, 8)}01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else if (month == "0" && year != "0")
{
DateTime now = DateTime.Now;
string startStr = $"{year}/{now.ToFarsi().Substring(5, 2)}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else if (month != "0" && year == "0")
{
DateTime now = DateTime.Now;
string startStr = $"{now.ToFarsi().Substring(0, 4)}/{month}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else
{
string startStr = $"{year}/{month}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
}
var timer = new Stopwatch();
timer.Start();
var contracts = _context.Contracts.AsSplitQuery()
.Where(x => x.WorkshopIds == workshopId && x.IsActiveString == "true" && startSreach < x.ContractEnd &&
endSearch > x.ContarctStart)
.Join(_context.Workshops.AsSplitQuery(),
contract => contract.WorkshopIds,
workshop => workshop.id,
(contract, workshop) => new { contract, workshop })
.Join(_context.Employees.AsSplitQuery(),
contractWorkshop => contractWorkshop.contract.EmployeeId,
employee => employee.id,
(contractWorkshop, employee) => new { contractWorkshop, employee })
.Join(_context.LeftWorkList.AsSplitQuery().Where(l => l.WorkshopId == workshopId && l.StartWorkDate < endSearch && l.LeftWorkDate > startSreach),
contractWorkshopEmployee => contractWorkshopEmployee.contractWorkshop.contract.EmployeeId,
leftwork => leftwork.EmployeeId,
(contractWorkshopEmployee, leftwork) => new { contractWorkshopEmployee, leftwork })
.Join(_context.PersonnelCodeSet.AsSplitQuery().Where(p => p.WorkshopId == workshopId),
contractWorkshopEmployeeleftWork => contractWorkshopEmployeeleftWork.contractWorkshopEmployee
.contractWorkshop.contract.EmployeeId,
personnelCode => personnelCode.EmployeeId,
(contractWorkshopEmployeeleftWork, personnelCode) =>
new { contractWorkshopEmployeeleftWork, personnelCode })
.GroupJoin(_context.CheckoutSet.AsSplitQuery(),
contractWorkshopEmployeeleftWorkPersonnelCode => contractWorkshopEmployeeleftWorkPersonnelCode
.contractWorkshopEmployeeleftWork.contractWorkshopEmployee.contractWorkshop.contract.id,
checkout => checkout.ContractId,
(contractWorkshopEmployeeleftWorkPersonnelCode, checkout) =>
new { contractWorkshopEmployeeleftWorkPersonnelCode, checkout })
.ToList();
Console.WriteLine("query : " + timer.Elapsed);
timer.Reset();
timer.Start();
if (employeeId > 0)
contracts = contracts.Where(x =>
x.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.contract.EmployeeId == employeeId).ToList();
var finalResult = contracts.Select(result =>
{
var now = DateTime.Now;
DateTime currentStart = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
DateTime currentEnd = ($"{DateTime.Now.ToFarsi().FindeEndOfMonth()}").ToGeorgianDateTime();
var chekoutCreated = result.checkout.FirstOrDefault(x => x.ContractStart < endSearch && x.ContractEnd > startSreach && x.IsActiveString == "true");
if (chekoutCreated != null)
{
return new CreateCheckoutListViewModel
{
Id = chekoutCreated.ContractId,
EmployeeId = chekoutCreated.EmployeeId,
ContractNo = chekoutCreated.ContractNo,
WorkshopName = chekoutCreated.WorkshopName,
EmployeeName = chekoutCreated.EmployeeFullName,
ContractStart = chekoutCreated.ContractStart.ToFarsi(),
ContractEnd = chekoutCreated.ContractEnd.ToFarsi(),
PersonnelCode = Convert.ToInt64(chekoutCreated.PersonnelCode),
LaterThanEnd = false,
Extension = false,
Description = "دارای فیش حقوقی",
HasCheckout = true
};
}
var employeeJoin = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.employee.id;
bool hasRollCall =
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startSreach, endSearch);
var leftWork = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.leftwork;
bool extension = true;
bool laterThanEnd = false;
string description = "";
string leftWorkDate="";
string contractStart = "";
string contractEnd = "";
var contractStartGr = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.contract.ContarctStart;
var contractEndGr = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.contract.ContractEnd;
#region HasRollCall
if (hasRollCall)
{
// اگر ترک کار کرده بود
// اگر ترک کارش در بازه انتخاب شده بود
if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
{
//اگر بازه انتخاب شده در تاریخ جاری بود
if (startSreach == currentStart && endSearch == currentEnd)
{
//اگر ترک کارش قبل یا مساوی تاریخ جاری بود
if (leftWork.LeftWorkDate <= now)
{
//مجاز به ایجاد تصفیه
extension = true;
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
}
else
{
// مجاز نیست
extension = false;
description = "بعد از تاریخ ترک کار می توانید فیش صادر کنید";
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
}
}
else if (endSearch < currentStart)
{
extension = true;
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
}
else if (startSreach > currentEnd)
{
// مجاز نیست
extension = false;
description = "بعد از تاریخ ترک کار می توانید فیش صادر کنید";
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
}
}
else if (leftWork.HasLeft && leftWork.LeftWorkDate <= startSreach)
{
// مجاز نیست
extension = false;
description = "به دلیل ترک کار پیش از تاریخ انتخاب شده مجاز به ایجاد فیش نمی باشید";
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
}
else if (!leftWork.HasLeft && startSreach == currentStart)
{
// مجاز نیست
extension = false;
description = "به دلیل داشتن حضورغیاب تا پایان ماه مجاز به ایجاد فیش نمی باشید";
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
else if (!leftWork.HasLeft && startSreach < currentStart)
{
if (contractStartGr <= startSreach && contractStartGr > endSearch)
{
laterThanEnd = true;
extension = true;
contractStart = startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
else
{
laterThanEnd = false;
extension = true;
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = (leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch) ? leftWork.LeftWorkDate.AddDays(-1).ToFarsi() : endSearch.ToFarsi();
}
}
}
#endregion
#region Static
if (!hasRollCall)
{
if (leftWork.HasLeft)
{
if (leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
{
extension = true;
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
}
else if (leftWork.LeftWorkDate <= startSreach)
{
// مجاز نیست
extension = false;
description = "به دلیل ترک کار پیش از تاریخ انتخاب شده مجاز به ایجاد فیش نمی باشید";
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
}
else if(leftWork.LeftWorkDate > endSearch)
{
extension = true;
if (contractStartGr <= startSreach && contractStartGr > endSearch)
{
laterThanEnd = true;
contractStart = startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
else
{
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
}
}
else
{
extension = true;
if (contractStartGr <= startSreach && contractStartGr > endSearch)
{
laterThanEnd = true;
contractStart = startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
else
{
contractStart = leftWork.StartWorkDate > startSreach
? leftWork.StartWorkDate.ToFarsi()
: startSreach.ToFarsi();
contractEnd = endSearch.ToFarsi();
}
}
}
#endregion
return new CreateCheckoutListViewModel
{
Id = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.contract.id,
EmployeeId = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.employee.id,
ContractNo = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.contract.ContractNo,
//EmployerName = result.contract.EmployerName,
WorkshopName = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.contractWorkshop.workshop.WorkshopFullName,
EmployeeName = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.employee.FullName,
PersonnelCode = result.contractWorkshopEmployeeleftWorkPersonnelCode.personnelCode.PersonnelCode,
//PersonnelCodeInt = Convert.ToInt32(result.contract.PersonnelCode),
LaterThanEnd = laterThanEnd,
Extension = extension,
Description = description,
ContractStart = contractStart,
ContractEnd = contractEnd,
LeftWorkDate = leftWorkDate
};
}).OrderByDescending(x=>x.Extension).ToList();
Console.WriteLine("process : " + timer.Elapsed);
return new CreateCheckoutListViewModel()
{
CreateCheckoutList = finalResult
};
}
public async Task CreateCkeckout(Checkout command)
{
@@ -1146,14 +1508,20 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
var firstRollCall = orderedRollcalls.FirstOrDefault();
var secondRollCall = orderedRollcalls.Skip(1).FirstOrDefault();
DateTime? secondRCEndDate = null;
DateTime? firstRCEndDate = null;
if (firstRollCall != null)
firstRCEndDate = firstRollCall.ShiftEndWithoutRest ?? firstRollCall.EndDate;
if (secondRollCall != null)
secondRCEndDate = secondRollCall.ShiftEndWithoutRest ?? secondRollCall.EndDate;
var firstRCEndDate = firstRollCall.ShiftEndWithoutRest ?? firstRollCall.EndDate;
var secondRCEndDate = secondRollCall.ShiftEndWithoutRest ?? secondRollCall.EndDate;
return new CheckoutDailyRollCallViewModel()
{
StartDate1 = firstRollCall?.StartDate?.ToString("HH:mm") ?? "",
EndDate1 =firstRCEndDate?.ToString("HH:mm") ?? "",
EndDate1 = firstRCEndDate?.ToString("HH:mm") ?? "",
StartDate2 = secondRollCall?.StartDate?.ToString("HH:mm") ?? "",
EndDate2 = secondRCEndDate?.ToString("HH:mm") ?? "",

View File

@@ -1173,7 +1173,17 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
}
@@ -1194,7 +1204,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
{
WorkshopId = x.Key,
WorkshopFullName = x.FirstOrDefault().Workshop.WorkshopName,
WorkshopFullName = x.FirstOrDefault().Workshop.WorkshopFullName,
EmployeesWithoutDocumentCount = x.Count()
});
@@ -1301,7 +1311,19 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
};
}).ToList();
return result;
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
}
public async Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetClientRejectedDocumentWorkshopsForAdmin(List<long> workshops, long roleId)
@@ -1463,9 +1485,19 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
return result;
}
public async Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentForClient(long workshopId, long accountId)
@@ -1568,8 +1600,18 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
return result;
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
}
//ToDo آپلود مدارک و افزودن پرسنل
@@ -1646,8 +1688,12 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
};
}
private static string GetThumbnailPathFromFilePath(string filePath)
{
return string.IsNullOrWhiteSpace(filePath) ? string.Empty : Path.Combine(Path.GetDirectoryName(filePath)!, Path.GetFileNameWithoutExtension(filePath) + $"-thumbnail{Path.GetExtension(filePath)}");
}
private static EmployeeDocumentItemViewModel GetByLabelAndLoadMedia(List<EmployeeDocumentItemViewModel> items,
private static EmployeeDocumentItemViewModel GetByLabelAndLoadMedia(List<EmployeeDocumentItemViewModel> items,
List<MediaViewModel> medias, DocumentItemLabel label)
{
if (items == null || items.Count == 0)

File diff suppressed because it is too large Load Diff

View File

@@ -397,7 +397,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
TypeOfContract = x.TypeOfContract,
Signature = x.Signature,
ExpireColor = ExpColor(x.ContractEndGr, x.SearchAmount,
x.IsActiveString),
x.IsActiveString).result,
IsExpier = ExpColor(x.ContractEndGr, x.SearchAmount,
x.IsActiveString).isExpier,
BalanceDouble = TotalBalance(x.ContractingPartyId).TotalBalanceDbl,
BalanceStr = TotalBalance(x.ContractingPartyId).TotalBalanceStr,
EmployerViewModels = x.EmployerViewModels,
@@ -441,6 +443,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
TypeOfContract = x.TypeOfContract,
Signature = x.Signature,
ExpireColor = x.ExpireColor,
IsExpier = x.IsExpier,
BalanceDouble = x.BalanceDouble,
BalanceStr = x.BalanceStr,
EmployerViewModels = x.EmployerViewModels,
@@ -458,7 +461,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
.ThenBy(x => x.ExpireColor == "red")
.ThenBy(x => x.IsExpier == "true")
.ThenBy(x => x.ExpireColor == "purple")
.ThenBy(x => x.ExpireColor == "black").ToList();
Console.WriteLine("test >>> " + timer.Elapsed);
@@ -577,7 +580,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
return res;
}
public string ExpColor(DateTime contractEndGr, double contractAmount,
public (string result, string isExpier) ExpColor(DateTime contractEndGr, double contractAmount,
string isActiveString)
{
var now = DateTime.Now;
@@ -585,16 +588,35 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var endFa = nowFa.FindeEndOfMonth();
var endThisMontGr = endFa.ToGeorgianDateTime();
string result = "";
string isExpier = "false";
if (contractEndGr < now)
{
result = "black";
isExpier = "true";
}
if (contractEndGr >= now && contractEndGr <= endThisMontGr)
{
result = "red";
isExpier = "true";
}
if (contractAmount == 0)
{
result = "purple";
if ((contractEndGr >= now && contractEndGr <= endThisMontGr) || (contractEndGr < now))
{
isExpier = "true";
}
}
if (isActiveString == "blue")
{
result = "blue";
return result;
isExpier = "false";
}
return (result, isExpier);
}

Some files were not shown because too many files have changed in this diff Show More