Compare commits

...

81 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
SamSys
5f7f63689c build tailwind 2025-06-03 16:51:34 +03:30
SamSys
7db754af56 Merge branch 'Feature/Register/Init' into Upload/dad-mehr 2025-06-03 16:49:18 +03:30
SamSys
87afbbe44c change of register 2025-06-03 16:48:42 +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
5fa49a4988 change main pages 2025-06-01 18:23:51 +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
SamSys
5576ee5c24 api started 2025-05-30 23:04:53 +03:30
SamSys
42ea521e0b set Salary in create employee by Client merged 2025-05-27 21:38:14 +03:30
SamSys
c608e22062 AMO merged 2025-05-25 21:40:54 +03:30
MahanCh
bb80da6e3b add set salary tab in create employee 2025-05-25 19:24:29 +03:30
SamSys
4c734e0513 Camera icon Task merged 2025-05-21 21:39:17 +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
cc3812ebee Static merged 2025-05-20 22:41:55 +03:30
MahanCh
99e807fa23 fix step4 bug 2025-05-20 17:45:43 +03:30
SamSys
17e390d840 ReCalculateValues Merged 2025-05-19 21:32:09 +03:30
SamSys
f4a16b8c69 Rgister Merge 2025-05-19 21:30:36 +03:30
MahanCh
2ce17dcac9 change some styles 2025-05-19 18:04:47 +03:30
MahanCh
233c1a3aa9 merge from master 2025-05-19 18:04:36 +03:30
SamSys
c2fa992369 Employer Confirm Insurance 2025-05-18 21:18:23 +03:30
SamSys
922ab6f32b RotatingShifrtReport Merged 2025-05-18 21:17:21 +03:30
SamSys
0eee2a53c3 register merged 2025-05-18 21:13:52 +03:30
MahanCh
37cd07c2b8 fix conflict 2025-05-18 17:54:55 +03:30
MahanCh
6201492879 change step4 2025-05-18 17:52:33 +03:30
SamSys
b0f5ec6bbd change 2025-05-14 21:37:12 +03:30
SamSys
9ef48b982d Mearge RecalCulate Valuse group 2025-05-14 21:33:38 +03:30
SamSys
2a306dedac merge New Version of RegisterFinancial 2025-05-14 21:31:56 +03:30
SamSys
489528d076 new version of Register 2025-05-14 21:24:06 +03:30
SamSys
400790a53b RotatingShiftReport BackEnd Changed 2025-05-14 18:53:34 +03:30
SamSys
6a2ff178d3 push 2025-05-13 22:15:06 +03:30
SamSys
5f64b945d1 RotatingShiftReport client 2025-05-13 21:37:41 +03:30
SamSys
280a475455 sepration contract index js on client 2025-05-13 13:06:56 +03:30
SamSys
a7b91fac18 merged loan and SalaryAid to OfficialCheckout 2025-05-12 21:26:07 +03:30
MahanCh
fcea7eed21 merge 2025-05-10 16:41:14 +03:30
MahanCh
0a293dfa8c fix application 2025-05-10 16:18:18 +03:30
MahanCh
5825c7b8e2 fix bug 2025-05-10 16:01:09 +03:30
ebdf26d93c merge from edit checkout on change salary aid and .... 2025-05-09 13:45:25 +03:30
SamSys
67ec735778 Register changes 2025-05-07 22:53:41 +03:30
MahanCh
3a6f87eaca fix some register financial bugs 2025-05-07 22:45:42 +03:30
MahanCh
1ebbd2d7a9 Merge branch 'Feature/EmployeeDocuments/V2' into Upload/dad-mehr 2025-05-06 14:17:32 +03:30
SamSys
a40a9643f4 employee document workflow V2 2025-05-05 22:08:00 +03:30
SamSys
55c139578d add workshopSetting page in client 2025-05-05 22:07:01 +03:30
MahanCh
e9588125c0 merge from register financial 2025-05-04 20:59:42 +03:30
MahanCh
ec277629fb fix register financial problems 2025-05-04 20:58:45 +03:30
SamSys
bf9c317565 uid autorize for create employee in admin side 2025-05-03 15:42:46 +03:30
SamSys
22bd435627 ReCalculate rollcall values in CWEs "PersonnelShiftChange" 2025-04-30 21:27:41 +03:30
MahanCh
423d6ada9b Merge branch 'Feature/Register/Init' into Upload/dad-mehr 2025-04-28 15:50:51 +03:30
MahanCh
faeb297f5c fix register problems 2025-04-28 15:49:56 +03:30
SamSys
8bdfd44bba fix bug 2025-04-27 21:57:28 +03:30
SamSys
104534ed96 CalculationDate for SalaryAid 2025-04-27 21:43:00 +03:30
MahanCh
c00a9c0864 fix task size validation 2025-04-27 20:52:04 +03:30
MahanCh
cdb29a80e1 Add Calculation date to salaryAid 2025-04-27 19:37:50 +03:30
MahanCh
c3457881b0 add register part 2025-04-23 23:22:26 +03:30
225 changed files with 72471 additions and 7292 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

@@ -41,6 +41,23 @@ public static class Tools
return Regex.IsMatch(mobileNo, "^((09))(\\d{9})$");
}
/// <summary>
/// تاریخ شروع و تعداد ماه را میگیرد و تاریخ پایان قراردا را بر میگرداند
/// </summary>
/// <param name="startDate"></param>
/// <param name="monthPlus"></param>
/// <returns></returns>
public static (DateTime endDateGr, string endDateFa) FindEndOfContract(string startDate, string monthPlus)
{
int startYear = Convert.ToInt32(startDate.Substring(0, 4));
int startMonth = Convert.ToInt32(startDate.Substring(5, 2));
int startDay = Convert.ToInt32(startDate.Substring(8, 2));
var start = new PersianDateTime(startYear, startMonth, startDay);
var end = (start.AddMonths(Convert.ToInt32(monthPlus))).AddDays(-1);
return ($"{end}".ToGeorgianDateTime(), $"{end}");
}
/// <summary>
/// دریافت روزهای کارکرد پرسنل در لیست بیمه ماه مشخص شده

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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -0,0 +1,26 @@
using _0_Framework.Domain;
namespace Company.Domain.ContactUsAgg;
public class ContactUs:EntityBase
{
public ContactUs(string firstName, string lastName, string email, string phoneNumber, string title, string message)
{
FirstName = firstName.Trim();
LastName = lastName.Trim();
Email = email;
PhoneNumber = phoneNumber;
Title = title;
Message = message;
FullName = FirstName + " " + LastName;
}
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string Email { get; private set; }
public string PhoneNumber { get; private set; }
public string Title { get; private set; }
public string Message { get; private set; }
public string FullName { get; private set; }
}

View File

@@ -0,0 +1,8 @@
using _0_Framework.Domain;
namespace Company.Domain.ContactUsAgg;
public interface IContactUsRepository : IRepository<long, ContactUs>
{
}

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

@@ -213,6 +213,7 @@ public class CustomizeWorkshopEmployeeSettings : BaseCustomizeEntity
earlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
.ToList(), earlyExit.Value);
}
public void UpdateIsShiftChange()
{
var groupSetting = CustomizeWorkshopGroupSettings;
@@ -269,4 +270,10 @@ public class CustomizeWorkshopEmployeeSettings : BaseCustomizeEntity
IsShiftChanged = isShiftChange;
}
public void SetSalary(double salary)
{
Salary = salary;
}
}

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);
@@ -26,6 +38,12 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
List<LateToWorkEarlyExistSpannig> LateToWorkEarlyExit(List<GroupedRollCalls> groupedRollCall,
ICollection<CustomizeWorkshopEmployeeSettingsShift> shiftSettings, List<LeaveViewModel> leavList);
List<LoanInstallmentViewModel> LoanInstallmentForCheckout(long employeeId, long workshopId, DateTime contractStart,
DateTime contractEnd);
List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart,
DateTime checkoutEnd);
/// <summary>
/// گزارش نوبت کاری حضور غیاب
/// </summary>
@@ -35,12 +53,6 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
/// <param name="contractEnd"></param>
/// <param name="shiftwork"></param>
/// <returns></returns>
List<LoanInstallmentViewModel> LoanInstallmentForCheckout(long employeeId, long workshopId, DateTime contractStart,
DateTime contractEnd);
List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart,
DateTime checkoutEnd);
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
DateTime contractEnd, string shiftwork, bool hasRollCall, CreateWorkingHoursTemp command,bool holidayWorking);
}

View File

@@ -23,7 +23,6 @@ public class SalaryAid : EntityBase
CalculationMonth = calculationMonth;
CalculationYear = calculationYear;
}
public long EmployeeId { get; private set; }
public long WorkshopId { get; private set; }
public double Amount { get; private set; }

View File

@@ -14,5 +14,7 @@ public interface IWorkshopTempRepository : IRepository<long, WorkshopTemp>
/// <returns></returns>
Task<List<WorkshopTempViewModel>> GetWorkshopTemp(long contractingPartyTemp);
System.Threading.Tasks.Task RemoveWorkshopTemps(List<long> workshopTempIds);
}

View File

@@ -34,12 +34,14 @@ public class InstitutionContractTemp : EntityBase
/// بصورت یکجا
/// -
/// بصئورت ماهیانه
/// OneTime
/// </summary>
public string PaymentModel { get; private set; }
/// <summary>
/// مدت قرارداد
/// چند ماهه؟
/// "12"
/// </summary>
public string PeriodModel { get; private set; }

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

@@ -0,0 +1,18 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.ContactUs;
public interface IContactUsApplication
{
OperationResult Create(CreateContactUs command);
}
public class CreateContactUs
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public string Title { get; set; }
public string Message { get; set; }
}

View File

@@ -8,6 +8,7 @@ public class CustomizeWorkshopGroupSettingsViewModel
{
public long Id { get; set; }
public double Salary { get; set; }
public string SalaryStr { get; set; }
public string GroupName { get; set; }
public bool MainGroup { get; set; }
public List<CustomizeWorkshopShiftViewModel> RollCallWorkshopShifts { get; set; }
@@ -18,4 +19,5 @@ public class CustomizeWorkshopGroupSettingsViewModel
public BreakTime BreakTime { get; set; }
public FridayWork FridayWork { get; set; }
public HolidayWork HolidayWork { get; set; }
public int LeavePermitted { get; set; }
}

View File

@@ -28,6 +28,10 @@ public class CreateEmployeeByClient
public List<AddEmployeeDocumentItem> EmployeeDocumentItems { get; set; }
public bool HasEmployeeDocument { get; set; }
public bool HasRollCallService { get; set; }
public bool HasCustomizeCheckoutService { get; set; }
}

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

@@ -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

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.InstitutionPlan;
@@ -38,7 +39,7 @@ public interface ITemporaryClientRegistrationApplication
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateOrUpdateWorkshopTemp(List<WorkshopTempViewModel> command);
Task<OperationResult> CreateOrUpdateWorkshopTemp(List<WorkshopTempViewModel> command, long contractingPartyTempId);
/// <summary>
/// دریافت جمع کل خدمات برای یک کارگاه
@@ -55,14 +56,14 @@ public interface ITemporaryClientRegistrationApplication
/// <param name="paymentModel"></param>
/// <returns></returns>
Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(long contractingPartyTempId,
string periodModel = "12", string paymentModel = "OneTime");
string periodModel = "12", string paymentModel = "OneTime", string contractStartType = "currentMonth");
/// <summary>
/// ایجاد یا ویرایش قرارداد موقت
/// </summary>
/// <param name="contractingPartyTempId"></param>
/// <returns></returns>
Task<OperationResult> CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax);
Task<OperationResult> CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax, DateTime contractStart);
/// <summary>
/// دریافت کد برای کلاینت

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.TemporaryClientRegistration;
public class MonthlyInstallment
{
/// <summary>
/// مبلغ قسط ماهانه
/// </summary>
public string InstallmentAmountStr { get; set; }
/// <summary>
/// تاریخ قسط ماهانه
/// </summary>
public string InstalmentDate { get; set; }
/// <summary>
/// شمارنده قسط
/// </summary>
public string InstallmentCounter{ get; set; }
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.TemporaryClientRegistration;
@@ -23,28 +24,54 @@ public class ReviewAndPaymentViewModel
/// مبلغ پرداخت بدون مالیات
/// Double
/// </summary>
public double WithoutTaxPaymentDouble { get; set; }
public double OneTimeWithoutTaxPaymentDouble { get; set; }
/// <summary>
/// مبلغ پرداخت بدون مالیات
/// string
/// </summary>
public string WithoutTaxPaymentStr { get; set; }
public string OneTimeWithoutTaxPaymentStr { get; set; }
/// <summary>
/// مبلغ پرداخت کامل
/// Double
/// </summary>
public double TotalPaymentDouble { get; set; }
public double OneTimeTotalPaymentDouble { get; set; }
/// <summary>
/// مبلغ پرداخت کامل
/// string
/// </summary>
public string TotalPaymentStr { get; set; }
public string OneTimeTotalPaymentStr { get; set; }
/// <summary>
/// مبلغ پرداخت بدون مالیات
/// Double
/// </summary>
public double MonthlyWithoutTaxPaymentDouble { get; set; }
/// <summary>
/// مبلغ پرداخت بدون مالیات
/// string
/// </summary>
public string MonthlyWithoutTaxPaymentStr { get; set; }
/// <summary>
/// مبلغ پرداخت کامل
/// Double
/// </summary>
public double MonthlyTotalPaymentDouble { get; set; }
/// <summary>
/// مبلغ پرداخت کامل
/// string
/// </summary>
public string MonthlyTotalPaymentStr { get; set; }
/// <summary>
/// مالیات بر ارزش افزوده
/// Double
@@ -83,4 +110,52 @@ public class ReviewAndPaymentViewModel
/// آی دی طرف حساب
/// </summary>
public long ContractingPartTempId { get; set; }
/// <summary>
/// لیست اقساط ماهیانه
/// </summary>
public List<MonthlyInstallment> MonthlyInstallments { get; set; }
/// <summary>
/// تاریخ شروع قرارداد در اول ماه جاری
/// -
/// شمسی
/// </summary>
public string ContractStartCurrentMonthFa { get; set; }
/// <summary>
/// تاریخ شروع قرارداد در اول ماه جاری
/// -
/// میلادی
/// </summary>
public DateTime ContractStartCurrentMonthGr { get; set; }
/// <summary>
/// تاریخ شروع قرارداد در اول ماه بعد
/// -
/// شمسی
/// </summary>
public string ContractStartNextMonthFa{ get; set; }
/// <summary>
/// تاریخ شروع قرارداد در اول ماه بعد
/// -
/// میلادی
/// </summary>
public DateTime ContractStartNextMonthGr { get; set; }
/// <summary>
/// تاریخ پایان قرارداد
/// -
/// میلادی
/// </summary>
public DateTime ContractEndGr { get; set; }
/// <summary>
/// تاریخ پایان قرارداد
/// -
/// شمسی
/// </summary>
public string ContractEndFa { 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

@@ -0,0 +1,70 @@
using System.Text.RegularExpressions;
using _0_Framework.Application;
using Company.Domain.ContactUsAgg;
using CompanyManagment.App.Contracts.ContactUs;
namespace CompanyManagment.Application;
public class ContactUsApplication : IContactUsApplication
{
private readonly IContactUsRepository _contactUsRepository;
public ContactUsApplication(IContactUsRepository contactUsRepository)
{
_contactUsRepository = contactUsRepository;
}
public OperationResult Create(CreateContactUs command)
{
var op = new OperationResult();
if (string.IsNullOrWhiteSpace(command.FirstName))
{
return op.Failed("لطفا نام خود را وارد کنید");
}
if (string.IsNullOrWhiteSpace(command.LastName))
{
return op.Failed("لطفا نام خانوادگی خود را وارد کنید");
}
if (string.IsNullOrWhiteSpace(command.Email))
{
return op.Failed("لطفا ایمیل خود را وارد کنید");
}
if (string.IsNullOrWhiteSpace(command.PhoneNumber))
{
return op.Failed("لطفا شماره تماس خود را وارد کنید");
}
if (!Regex.IsMatch(command.PhoneNumber, @"^(\+98|0)?9\d{9}$"))
{
return op.Failed("شماره تماس وارد شده نامعتبر است");
}
if (!Regex.IsMatch(command.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
{
return op.Failed("ایمیل وارد شده نامعتبر است");
}
if (string.IsNullOrWhiteSpace(command.Title))
{
return op.Failed("لطفا عنوان پیغام خود را وارد کنید");
}
if (string.IsNullOrWhiteSpace(command.Message))
{
return op.Failed("لطفا پیغام خود را وارد کنید");
}
var entity = new ContactUs(command.FirstName, command.LastName, command.Email, command.PhoneNumber,
command.Title, command.Message);
_contactUsRepository.Create(entity);
_contactUsRepository.SaveChanges();
return op.Succcedded();
}
}

View File

@@ -19,12 +19,13 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Transactions;
using CompanyManagment.App.Contracts.RollCall;
using Microsoft.EntityFrameworkCore.Query;
using Company.Domain.CheckoutAgg;
using Company.Domain.CustomizeCheckoutAgg;
using Company.Domain.CustomizeCheckoutTempAgg;
using CompanyManagment.EFCore.Repository;
using CompanyManagment.App.Contracts.RollCall;
using Hangfire.States;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.EntityFrameworkCore.Query;
namespace CompanyManagment.Application;
@@ -372,10 +373,10 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
}
if (customizeWorkshopGroupSettings.MainGroup)
{
var createDefaultEmployee = CreateEmployeeSettings(command);
return createDefaultEmployee;
}
{
var createDefaultEmployee = CreateEmployeeSettings(command);
return createDefaultEmployee;
}
List<CustomizeWorkshopEmployeeSettingsShift> shiftCollection = new List<CustomizeWorkshopEmployeeSettingsShift>();
@@ -557,7 +558,13 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
_customizeWorkshopEmployeeSettingsRepository.Create(entity);
entity.SimpleEdit(shiftCollection, command.IrregularShift, command.WorkshopShiftStatus, command.BreakTime, isChanged, command.FridayWork, command.HolidayWork, rotatingShift);
entity.SimpleEdit(shiftCollection, command.IrregularShift, command.WorkshopShiftStatus, command.BreakTime, isChanged, command.FridayWork, command.HolidayWork, rotatingShift);
var employeeSalary = command.Salary?.MoneyToDouble() ?? 0;
if (employeeSalary > 0)
{
entity.SetSalary(employeeSalary);
}
_customizeWorkshopGroupSettingsRepository.SaveChanges();
return op.Succcedded();
@@ -681,7 +688,7 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
return op.Succcedded();
}
public OperationResult EditSimpleRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command,
List<ReCalculateRollCallValues> reCalculateCommand)
List<ReCalculateRollCallValues> reCalculateCommand)
{
OperationResult op = new();
@@ -712,15 +719,15 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
{
groupSettingsShifts = command.ShiftViewModel.Select(x =>
{
if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
throw new InvalidDataException();
if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
throw new InvalidDataException();
{
if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
throw new InvalidDataException();
if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
throw new InvalidDataException();
return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
}).ToList();
}).ToList();
if (groupSettingsShifts.All(x => workshopSettings.CustomizeWorkshopSettingsShifts.Any(y => x.Equals(y)))
&& command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus && command.FridayWork == workshopSettings.FridayWork &&
@@ -1589,10 +1596,6 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
return _customizeWorkshopGroupSettingsRepository.GetEmployeesGroupSettingsByEmployeeId(employeeId, workshopId);
}
public bool HasAnyEmployeeWithoutGroup(long workshopId)
{
return _customizeWorkshopGroupSettingsRepository.HasAnyEmployeeWithoutGroup(workshopId);
}
public OperationResult<List<long>> ValidateReCalculateValueForGroupEdit(List<ReCalculateRollCallValues> commands,
long workshopId)
{
@@ -1623,10 +1626,16 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
employeeIdsHasCheckout = employeeIdsHasCheckout.Distinct().ToList();
return isSuccess ?
operationResult.Succcedded(employeeIdsHasCheckout)
operationResult.Succcedded(employeeIdsHasCheckout)
:
operationResult.Failed("پرسنل هایی دارای فیش هستند لطفا نسبت به تعیین تکلیف این ها اقدام نمایید", employeeIdsHasCheckout);
}
public bool HasAnyEmployeeWithoutGroup(long workshopId)
{
return _customizeWorkshopGroupSettingsRepository.HasAnyEmployeeWithoutGroup(workshopId);
}
public bool CheckEmployeeShiftHasChanged(EditCustomizeEmployeeSettings command)
{
return _customizeWorkshopEmployeeSettingsRepository.CheckEmployeeShiftHasChanged(command);

View File

@@ -1,35 +1,39 @@
using System;
using System.IO;
using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.EmployeeAgg;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.EFCore;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
using Company.Domain.EmployeeInsuranceRecordAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
using CompanyManagment.EFCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Transactions;
using Company.Domain.EmployeeClientTempAgg;
using Company.Domain.PersonnelCodeAgg;
using EmployeeInsuranceRecord = Company.Domain.EmployeeInsuranceRecordAgg.EmployeeInsuranceRecord;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using _0_Framework.Application.UID;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
using Company.Domain.EmployeeDocumentsAgg;
using Company.Domain.LeftWorkTempAgg;
using Company.Domain.RollCallEmployeeAgg;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
using CompanyManagment.App.Contracts.EmployeeDocuments;
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using System.Transactions;
using Company.Domain.EmployeeClientTempAgg;
using Company.Domain.LeftWorkTempAgg;
using CompanyManagment.App.Contracts.LeftWorkTemp;
using _0_Framework.Application.UID;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
using Company.Domain.EmployeeDocumentsAgg;
using Company.Domain.RollCallEmployeeAgg;
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
using Company.Domain.LeftWorkAgg;
using RollCallEmployee = Company.Domain.RollCallEmployeeAgg.RollCallEmployee;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.LeftWorkTemp;
using System.Reflection;
using Company.Domain.EmployeeAuthorizeTempAgg;
using Company.Domain.RollCallServiceAgg;
using Microsoft.Extensions.Configuration;
using Company.Domain.LeftWorkInsuranceAgg;
namespace CompanyManagment.Application;
@@ -37,6 +41,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
private readonly IEmployeeRepository _EmployeeRepository;
private readonly IWorkshopRepository _WorkShopRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IPersonnelCodeRepository _personnelCodeRepository;
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
private readonly CompanyContext _context;
public bool nationalCodValid = false;
public bool idnumberIsOk = true;
@@ -54,16 +61,32 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
private readonly IUidService _uidService;
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IPersonnelCodeRepository _personnelCodeRepository;
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
private readonly IEmployeeAuthorizeTempRepository _employeeAuthorizeTempRepository;
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository ;
private readonly IRollCallServiceRepository _rollCallServiceRepository;
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository) : base(context)
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context,
IWorkshopRepository workShopRepository,
ILeftWorkRepository leftWorkRepository, IPersonnelCodeRepository personnelCodeRepository,
IEmployeeClientTempRepository employeeClientTempRepository, IWebHostEnvironment webHostEnvironment,
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication,
IRollCallEmployeeRepository rollCallEmployeeRepository,
ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository,
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;
_personnelCodeRepository = personnelCodeRepository;
_employeeClientTempRepository = employeeClientTempRepository;
_webHostEnvironment = webHostEnvironment;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_rollCallEmployeeRepository = rollCallEmployeeRepository;
@@ -73,18 +96,17 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_leftWorkTempRepository = leftWorkTempRepository;
_uidService = uidService;
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
_personnelCodeRepository = personnelCodeRepository;
_employeeClientTempRepository = employeeClientTempRepository;
_leftWorkRepository = leftWorkRepository;
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_EmployeeRepository = employeeRepository;
_rollCallServiceRepository = rollCallServiceRepository;
}
public OperationResult Create(CreateEmployee command)
{
var opration = new OperationResult();
if (_EmployeeRepository.Exists(x =>
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.NationalCode != null && x.IsActiveString == "true"))
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.NationalCode != null))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
//if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber !=null))
@@ -102,7 +124,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
//}
if (command.Address != null && command.State == null)
{
@@ -141,8 +163,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
case "0000000000":
case "1111111111":
case "22222222222":
case "33333333333":
case "2222222222":
case "3333333333":
case "4444444444":
case "5555555555":
case "6666666666":
@@ -194,9 +216,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("کد ملی وارد شده تکراری است");
}
}
string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
@@ -221,9 +243,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Succcedded(employeeData.id);
}
public OperationResult Edit(EditEmployee command)
{
var opration = new OperationResult();
@@ -232,11 +255,11 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("رکورد مورد نظر یافت نشد");
if (_EmployeeRepository.Exists(x =>
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.id != command.Id && x.IsActiveString == "true"))
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.id != command.Id))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
//if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber != null && x.id != command.Id))
// return opration.Failed("شماره شناسنامه وارد شده تکراری است");
if (command.Address != null && command.State == null)
{
StatCity = false;
@@ -274,8 +297,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
case "0000000000":
case "1111111111":
case "22222222222":
case "33333333333":
case "2222222222":
case "3333333333":
case "4444444444":
case "5555555555":
case "6666666666":
@@ -328,7 +351,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}
}
string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
@@ -336,7 +359,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
dateOfIssue,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,
command.Phone, command.Address,
command.State,command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
command.FieldOfStudy, command.BankCardNumber,
command.BankBranch, command.InsuranceCode, command.InsuranceHistoryByYear,
command.InsuranceHistoryByMonth, command.NumberOfChildren, command.OfficePhone
@@ -349,7 +372,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Succcedded();
}
public EditEmployee GetDetails(long id)
@@ -357,6 +380,11 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return _EmployeeRepository.GetDetails(id);
}
public EditEmployee GetDetailsIgnoreQueryFilter(long id)
{
return _EmployeeRepository.GetDetails(id);
}
public OperationResult Active(long id)
{
var opration = new OperationResult();
@@ -395,8 +423,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
public async Task<List<EmployeeViewModel>> Search(EmployeeSearchModel searchModel)
{
var res=await _EmployeeRepository.Search(searchModel);
var res = await _EmployeeRepository.Search(searchModel);
foreach (var item in res)
{
var children = _context.EmployeeChildrenSet.Count(x => x.EmployeeId == item.Id);
@@ -687,8 +715,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
case "0000000000":
case "1111111111":
case "22222222222":
case "33333333333":
case "2222222222":
case "3333333333":
case "4444444444":
case "5555555555":
case "6666666666":
@@ -817,8 +845,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
case "0000000000":
case "1111111111":
case "22222222222":
case "33333333333":
case "2222222222":
case "3333333333":
case "4444444444":
case "5555555555":
case "6666666666":
@@ -898,11 +926,17 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return res;
}
#endregion
#region Pooya
public List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId)
{
return _EmployeeRepository.GetWorkingEmployeesByWorkshopId(workshopId);
}
public EmployeeViewModel GetEmployeeByNationalCodeIfHasActiveLeftWork(string nationalCode, List<long> workshopIds)
{
if (nationalCode.NationalCodeValid() != "valid")
@@ -910,7 +944,6 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
var workshopEmployeesWithLeftWork = _EmployeeRepository.GetWorkingEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode, DateTime.Now.Date);
return workshopEmployeesWithLeftWork.FirstOrDefault();
}
public EmployeeViewModel GetEmployeeByNationalCodeIfHasLeftWork(string nationalCode, List<long> workshopIds)
{
if (nationalCode.NationalCodeValid() != "valid")
@@ -918,11 +951,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
var workshopEmployeesWithLeftWork = _EmployeeRepository.GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode, DateTime.Now.Date);
return workshopEmployeesWithLeftWork.FirstOrDefault();
}
public List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId)
{
return _EmployeeRepository.GetWorkingEmployeesByWorkshopId(workshopId);
}
public List<EmployeeViewModel> GetRangeByIds(IEnumerable<long> employeeIds)
{
@@ -958,6 +988,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}).ToList();
}
#endregion
#region Mahan
@@ -1009,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)
@@ -1024,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);
@@ -1041,6 +1080,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_personnelCodeRepository.SaveChanges();
}
var rollCallService = _rollCallServiceRepository.GetActiveServiceByWorkshopId(command.WorkshopId);
if (string.IsNullOrWhiteSpace(command.RollCallUploadEmployeePicture?.Picture1) == false &&
string.IsNullOrWhiteSpace(command.RollCallUploadEmployeePicture?.Picture2) == false)
@@ -1050,14 +1090,14 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
Directory.CreateDirectory(directoryPath);
var filePath1 = Path.Combine(directoryPath) + $@"\1.jpg";
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture1, filePath1);
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture1, filePath1);
var filePath2 = Path.Combine(directoryPath) + $@"\2.jpg";
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture2, filePath2);
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture2, filePath2);
var rollCallEmployee =
@@ -1090,6 +1130,16 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
if (command.CreateCustomizeEmployeeSettings.GroupId > 0)
{
if (rollCallService?.HasCustomizeCheckoutService == "true")
{
var employeeSalary = command.CreateCustomizeEmployeeSettings.Salary?.MoneyToDouble() ?? 0;
if (employeeSalary < 1)
{
return op.Failed("لطفا حقوق پرسنل را وارد کنید");
}
}
if (_customizeWorkshopEmployeeSettingsRepository
.Exists(x => x.WorkshopId == workshop.Id && x.EmployeeId == employee.id))
{
@@ -1117,6 +1167,16 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}
else if (command.CreateCustomizeEmployeeSettings.GroupId > 0)
{
if (rollCallService?.HasCustomizeCheckoutService == "true")
{
var employeeSalary = command.CreateCustomizeEmployeeSettings.Salary?.MoneyToDouble() ?? 0;
if (employeeSalary < 1)
{
return op.Failed("لطفا حقوق پرسنل را وارد کنید");
}
}
if (_customizeWorkshopEmployeeSettingsRepository
.Exists(x => x.WorkshopId == workshop.Id && x.EmployeeId == employee.id))
{
@@ -1210,6 +1270,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
byte[] bytes = Convert.FromBase64String(subBase64);
System.IO.File.WriteAllBytes(filePath, bytes);
}
public async Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>>
ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate, long workshopId)
{
@@ -1499,9 +1560,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{
employee.EditAuthorizeEmployee(employee.DateOfIssue, employee.PlaceOfIssue,
employee.Phone, employee.Address, employee.State, employee.City, command.MaritalStatus,
command.MilitaryService, employee.LevelOfEducation, employee.FieldOfStudy,
command.MilitaryService, employee.LevelOfEducation, employee.FieldOfStudy,
employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode,
employee.InsuranceHistoryByYear, employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
employee.InsuranceHistoryByYear, employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
@@ -1615,6 +1676,5 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}
#endregion
}

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

@@ -134,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

@@ -67,7 +67,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
return op.Failed("شماره همراه نا معتبر است");
#endregion
@@ -141,6 +141,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
result.FName = createTemp.FName;
result.LName = createTemp.LName;
result.DateOfBirthFa = dateOfBirth;
result.FatherName = createTemp.FatherName;
result.IdNumberSerial = createTemp.IdNumberSerial;
result.IdNumber = idNumber;
return op.Succcedded(result);
@@ -188,7 +190,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public async Task<OperationResult> CreateOrUpdateWorkshopTemp(List<WorkshopTempViewModel> command)
public async Task<OperationResult> CreateOrUpdateWorkshopTemp(List<WorkshopTempViewModel> command, long contractingPartyTempId)
{
var op = new OperationResult();
var updateWorkshopList = command.Where(x => x.Id > 0).ToList();
@@ -196,10 +198,17 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
if (updateWorkshopList.Count == 0 && createNewWorkshopList.Count == 0)
return op.Failed("هیچ مجموعه ای ایجاد نشده است");
var oldWorkshops = await _workshopTempRepository.GetWorkshopTemp(contractingPartyTempId);
#region Update
if (updateWorkshopList.Count > 0)
{
var updateListIds = updateWorkshopList.Select(x => x.Id).ToList();
var oldWorkshopsIds = oldWorkshops.Select(x => x.Id).ToList();
var exceptWorkshops = oldWorkshopsIds.Except(updateListIds).ToList();
if (exceptWorkshops.Any())
await _workshopTempRepository.RemoveWorkshopTemps(exceptWorkshops);
foreach (var workshop in updateWorkshopList)
{
@@ -212,6 +221,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
workshop.RollCall == false && workshop.Insurance == false)
op.Failed($"برای مجموعه {workshop.WorkshopName} هیچ سرویسی انتخاب نشده است");
var existWorkshops = _workshopTempRepository.Get(workshop.Id);
if (existWorkshops != null)
{
if (workshop.ContractAndCheckout)
@@ -256,6 +266,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
if (workshop.CustomizeCheckout)
await _workshopServicesTempRepository.CreateAsync(
new WorkshopServicesTemp("CustomizeCheckout", workshop.CountPerson, workshop.Id));
await _workshopServicesTempRepository.SaveChangesAsync();
}
}
@@ -324,6 +336,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
if (workshop.CustomizeCheckout)
await _workshopServicesTempRepository.CreateAsync(
new WorkshopServicesTemp("CustomizeCheckout", workshop.CountPerson, createNewWorkshopTemp.id));
await _workshopServicesTempRepository.SaveChangesAsync();
}
}
@@ -352,8 +366,9 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
/// </summary>
/// <param name="contractingPartyTempId"></param>
/// <returns></returns>
public async Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(long contractingPartyTempId, string periodModel = "12", string paymentModel = "OneTime")
public async Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(long contractingPartyTempId, string periodModel = "12", string paymentModel = "OneTime", string contractStartType = "currentMonth")
{
//دریافت کارگاه ها
var workshops = await _workshopTempRepository.GetWorkshopTemp(contractingPartyTempId);
@@ -380,9 +395,10 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
_ => 12,
};
//رند کردن مبالغ کارگاه ها
var roundAmount = (int)(totalPayment1MonthDouble / 1000000) * 1000000;
var roundAmount = (((Convert.ToInt64(totalPayment1MonthDouble))) / 1000000) * 1000000;
double roundAmount2 = roundAmount;
//بدست آوردن جمع کل مبالغ کارگاه بر اساس مدت قراداد
result.SumOfWorkshopsPaymentDouble = roundAmount * months;
result.SumOfWorkshopsPaymentDouble = months * roundAmount2;
result.SumOfWorkshopsPaymentPaymentStr = result.SumOfWorkshopsPaymentDouble.ToMoney();
@@ -394,31 +410,112 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
//مالیات
result.ValueAddedTaxDouble = tenPercent;
result.ValueAddedTaxSt = tenPercent.ToMoney();
if (paymentModel == "OneTime")//تخفیف 10 درصدی درصورت پرداخت یکجا
//پرداخت یکجا
#region OneTimePaymentResult
double discountOneTimePeyment = result.SumOfWorkshopsPaymentDouble - tenPercent;
//مبلغ بدون مالیات و با تخفیف
result.OneTimeWithoutTaxPaymentDouble = discountOneTimePeyment;
result.OneTimeWithoutTaxPaymentStr = discountOneTimePeyment.ToMoney();
//مبلغ با مالیات
result.OneTimeTotalPaymentDouble = discountOneTimePeyment + tenPercent;
result.OneTimeTotalPaymentStr = result.OneTimeTotalPaymentDouble.ToMoney();
#endregion
//پرداخت ماهیانه
#region MonthlyPaymentResult
//مبلغ بدون مالیات
result.MonthlyWithoutTaxPaymentDouble = result.SumOfWorkshopsPaymentDouble;
result.MonthlyWithoutTaxPaymentStr = result.SumOfWorkshopsPaymentDouble.ToMoney();
// مبلغ با مالیات
result.MonthlyTotalPaymentDouble = result.SumOfWorkshopsPaymentDouble + tenPercent;
result.MonthlyTotalPaymentStr = result.MonthlyTotalPaymentDouble.ToMoney();
var installmentList = new List<MonthlyInstallment>();
var startDate = (DateTime.Now).ToFarsi();
result.ContractStartCurrentMonthFa = $"{startDate.Substring(0, 8)}01";
result.ContractStartCurrentMonthGr = result.ContractStartCurrentMonthFa.ToGeorgianDateTime();
startDate = result.ContractStartCurrentMonthFa;
result.ContractStartNextMonthGr = ((startDate.FindeEndOfMonth()).ToGeorgianDateTime()).AddDays(1);
result.ContractStartNextMonthFa = result.ContractStartNextMonthGr.ToFarsi();
if (contractStartType == "nextMonth")
startDate = result.ContractStartNextMonthFa;
var findeEnd = Tools.FindEndOfContract(startDate, periodModel);
var contractEndDate = findeEnd.endDateGr;
result.ContractEndGr = contractEndDate;
result.ContractEndFa = contractEndDate.ToFarsi();
if (periodModel == "1")
{
double discountOneTimePeyment = result.SumOfWorkshopsPaymentDouble - tenPercent;
installmentList.Add(new MonthlyInstallment()
{
InstallmentAmountStr = result.MonthlyTotalPaymentStr,
InstallmentCounter = "سررسید پرداخت اول",
InstalmentDate = (DateTime.Now).ToFarsi()
//مبلغ بدون مالیات و با تخفیف
result.WithoutTaxPaymentDouble = discountOneTimePeyment;
result.WithoutTaxPaymentStr = discountOneTimePeyment.ToMoney();
//مبلغ با مالیات
result.TotalPaymentDouble = discountOneTimePeyment + tenPercent;
result.TotalPaymentStr = result.TotalPaymentDouble.ToMoney();
});
result.MonthlyInstallments = installmentList;
}
else
{
//مبلغ بدون مالیات
result.WithoutTaxPaymentDouble = result.SumOfWorkshopsPaymentDouble;
result.WithoutTaxPaymentStr = result.SumOfWorkshopsPaymentDouble.ToMoney();
int instalmentCount = Convert.ToInt32(periodModel);
var instalmentAmount = result.MonthlyTotalPaymentDouble / instalmentCount;
var findEndOfMonth = startDate.FindeEndOfMonth();
for (int i = 1; i <= instalmentCount; i++)
{
if (i == 1)
{
startDate = (DateTime.Now).ToFarsi();
}
else if (i > 1)
{
var currentMonthStart = ((findEndOfMonth.ToGeorgianDateTime()).AddDays(1)).ToFarsi();
startDate = currentMonthStart.FindeEndOfMonth();
findEndOfMonth = startDate;
}
installmentList.Add(new MonthlyInstallment()
{
InstallmentAmountStr = instalmentAmount.ToMoney(),
InstallmentCounter = i switch
{
1 => "سررسید پرداخت اول",
2 => "سررسید پرداخت دوم",
3 => "سررسید پرداخت سوم",
4 => "سررسید پرداخت چهارم",
5 => "سررسید پرداخت پنجم",
6 => "سررسید پرداخت ششم",
7 => "سررسید پرداخت هفتم",
8 => "سررسید پرداخت هشتم",
9 => "سررسید پرداخت نهم",
10 => "سررسید پرداخت دهم",
11 => "سررسید پرداخت یازدهم",
12 => "سررسید پرداخت دوازدهم",
_ => "سررسید پرداخت دوازدهم",
},
InstalmentDate = startDate
});
}
// مبلغ با مالیات
result.TotalPaymentDouble = result.SumOfWorkshopsPaymentDouble + tenPercent;
result.TotalPaymentStr = result.TotalPaymentDouble.ToMoney();
}
#endregion
result.MonthlyInstallments = installmentList;
result.ContractingPartTempId = contractingPartyTempId;
return result;
@@ -430,19 +527,21 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
/// </summary>
/// <param name="contractingPartyTempId"></param>
/// <returns></returns>
public async Task<OperationResult> CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax)
public async Task<OperationResult> CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax, DateTime contractStart)
{
var op = new OperationResult();
var institutionContractTemp = await
_institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId);
var contractStartDate = contractStart;
string contractStartFa = contractStart.ToFarsi();
var findeEnd = Tools.FindEndOfContract(contractStartFa, periodModel);
var contractEndDate = findeEnd.endDateGr;
if (institutionContractTemp == null)
{
var periodModelInt = Convert.ToInt32(periodModel);
var contractstart = DateTime.Now;
var contractEnd = DateTime.Now.AddMonths(periodModelInt);
var create = new InstitutionContractTemp(contractingPartyTempId,paymentModel,periodModel,totalPayment,contractstart,contractEnd,"official", valueAddedTax,"", "BeforeSendVerifyCode", 0,null,null);
var create = new InstitutionContractTemp(contractingPartyTempId, paymentModel, periodModel, totalPayment, contractStartDate, contractEndDate, "official", valueAddedTax, "", "BeforeSendVerifyCode", 0, null, null);
_institutionContractTempRepository.Create(create);
_institutionContractTempRepository.SaveChanges();
return op.Succcedded();
@@ -451,20 +550,20 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
{
if (institutionContractTemp.VerifyCodeEndTime != null)
{
var spaning = (institutionContractTemp.VerifyCodeEndTime.Value - DateTime.Now);
var spaning = (DateTime.Now - institutionContractTemp.VerifyCodeEndTime.Value);
if (institutionContractTemp.RegistrationStatus == "VerifyCodeSent" && spaning > new TimeSpan(0, 0, 0) && spaning < new TimeSpan(0, 1, 0))
return op.Failed("شما به تازگی پیامک دریافت نموده اید دو دقیقه صبر کنید و دوباره تلاش کنید");
}
if (institutionContractTemp.RegistrationStatus == "Completed")
return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید");
var periodModelInt = Convert.ToInt32(periodModel);
var contractstart = DateTime.Now;
var contractEnd = DateTime.Now.AddMonths(periodModelInt);
var update = _institutionContractTempRepository.Get(institutionContractTemp.Id);
update.Edit(contractingPartyTempId, paymentModel, periodModel, totalPayment, contractstart, contractEnd, "official", valueAddedTax, "", "BeforeSendVerifyCode", 0, null, null);
update.Edit(contractingPartyTempId, paymentModel, periodModel, totalPayment, contractStartDate, contractEndDate, "official", valueAddedTax, "", "BeforeSendVerifyCode", 0, null, null);
_institutionContractTempRepository.SaveChanges();
return op.Succcedded();
}
@@ -483,14 +582,14 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
{
var op = new OperationResult();
var institutionContractTemp = await
var institutionContractTemp = await
_institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId);
if (institutionContractTemp == null)
return op.Failed(ظا");
return op.Failed(طا");
var update = _institutionContractTempRepository.Get(institutionContractTemp.Id);
if (institutionContractTemp.RegistrationStatus == "BeforeSendVerifyCode")
@@ -516,26 +615,29 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
return op.Succcedded(1, "کد برای شما پیامک شد");
}
}
if (institutionContractTemp.RegistrationStatus == "VerifyCodeSent")
{
var spaning = (institutionContractTemp.VerifyCodeEndTime.Value - DateTime.Now);
if ((spaning > new TimeSpan(0, 0, 0) && spaning < new TimeSpan(0, 1, 0)))
if (DateTime.Now < institutionContractTemp.VerifyCodeEndTime.Value)
return op.Failed("کد دریافت شده را وارد کنید");
var spaning = (DateTime.Now - institutionContractTemp.VerifyCodeEndTime.Value);
if ((spaning > new TimeSpan(0, 0, 0) && spaning < new TimeSpan(0, 1, 0)))
return op.Failed("شما به تازگی پیامک دریافت نموده اید دو دقیقه صبر کنید و دوباره تلاش کنید");
if ((spaning > new TimeSpan(0, 0, 0) && spaning > new TimeSpan(0, 1, 0)))
if ((spaning > new TimeSpan(0, 1, 0)))
{
//ساخت کد شش رقمی
Random generator = new Random();
String code = generator.Next(1, 1000000).ToString("D6");
//ارسال اس ام اس
var getContractingPaty = _contractingPartyTempRepository.GetByContractingPartyTempId(contractingPartyTempId);
var sendResult =await _smsService.SendVerifyCodeToClient(getContractingPaty.Phone, code);
var sendResult = await _smsService.SendVerifyCodeToClient(getContractingPaty.Phone, code);
if(!sendResult.IsSuccedded)
if (!sendResult.IsSuccedded)
return op.Failed($"{sendResult.Message}");
@@ -544,16 +646,16 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
//ذخیره تاریخ ارسال و مهلت پایان
//ذخیره آیدی پیامک
//تغییر وضعیت به ارسال شده
if (update != null)
{
update.Update(code, "VerifyCodeSent",sendResult.MessageId, DateTime.Now, DateTime.Now.AddMinutes(2));
update.Update(code, "VerifyCodeSent", sendResult.MessageId, DateTime.Now, DateTime.Now.AddMinutes(2));
_institutionContractTempRepository.SaveChanges();
return op.Succcedded(1, "کد برای شما پیامک شد");
}
}
}
@@ -580,25 +682,25 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
_institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId);
if (institutionContractTemp == null)
return op.Failed("خظا");
if(institutionContractTemp.RegistrationStatus != "VerifyCodeSent")
if (institutionContractTemp.RegistrationStatus != "VerifyCodeSent")
return op.Failed("خطا");
if(institutionContractTemp.VerifyCodeEndTime < DateTime.Now)
if (institutionContractTemp.VerifyCodeEndTime < DateTime.Now)
return op.Failed("کد شما منقضی شده است");
if(institutionContractTemp.SendVerifyCodeTime < DateTime.Now && institutionContractTemp.VerifyCodeEndTime >= DateTime.Now)
if (institutionContractTemp.SendVerifyCodeTime < DateTime.Now && institutionContractTemp.VerifyCodeEndTime >= DateTime.Now)
{
if (institutionContractTemp.VerifyCode == verifyCode)
{
return op.Succcedded();
}
else
{
return op.Failed("کد وارد شده صحیح نیست");
}
}

View File

@@ -9,6 +9,7 @@ using Company.Domain.CheckoutAgg;
using Company.Domain.ClassifiedSalaryAgg;
using Company.Domain.ClientEmployeeWorkshopAgg;
using Company.Domain.Contact2Agg;
using Company.Domain.ContactUsAgg;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.ContractAgg;
using Company.Domain.ContractingPartyAccountAgg;
@@ -175,6 +176,8 @@ public class CompanyContext : DbContext
public DbSet<EmployeeClientTemp> EmployeeClientTemps { get; set; }
public DbSet<LeftWorkTemp> LeftWorkTemps { get; set; }
public DbSet<ContactUs> ContactUs { get; set; }
public DbSet<EmployeeAuthorizeTemp> EmployeeAuthorizeTemps { get; set; }
public DbSet<AdminMonthlyOverview> AdminMonthlyOverviews { get; set; }

View File

@@ -0,0 +1,20 @@
using Company.Domain.ContactUsAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class ContactUsMapping:IEntityTypeConfiguration<ContactUs>
{
public void Configure(EntityTypeBuilder<ContactUs> builder)
{
builder.HasKey(x => x.id);
builder.Property(x => x.FullName).HasMaxLength(200);
builder.Property(x => x.Title).HasMaxLength(200);
builder.Property(x => x.Email).HasMaxLength(200);
builder.Property(x => x.FirstName).HasMaxLength(100);
builder.Property(x => x.LastName).HasMaxLength(100);
builder.Property(x => x.Message).HasMaxLength(500);
builder.Property(x => x.PhoneNumber).HasMaxLength(20);
}
}

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

@@ -39,7 +39,7 @@ public class PersonalContractingpartyMapping : IEntityTypeConfiguration<Personal
builder.Property(x => x.IdNumberSerial).HasMaxLength(15);
builder.Property(x => x.FatherName).HasMaxLength(20);
builder.Property(x => x.DateOfBirth).IsRequired(false);
builder.Property(x => x.Gender).HasConversion(
builder.Property(x => x.Gender).HasConversion(
v => v.ToString(),
v => string.IsNullOrWhiteSpace(v) ? Gender.None : (Gender)Enum.Parse(typeof(Gender), v)).HasMaxLength(6);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addcontactus : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ContactUs",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
LastName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Email = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
PhoneNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
Message = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
FullName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactUs", x => x.id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ContactUs");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addsalaryAidcalculationdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addsalaryAidcalculationdatetocustomizecheckouts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

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;
@@ -559,6 +560,50 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("TextManager_Contact", (string)null);
});
modelBuilder.Entity("Company.Domain.ContactUsAgg.ContactUs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("FirstName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("FullName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("LastName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Message")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("PhoneNumber")
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<string>("Title")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("id");
b.ToTable("ContactUs");
});
modelBuilder.Entity("Company.Domain.ContarctingPartyAgg.PersonalContractingParty", b =>
{
b.Property<long>("id")
@@ -3350,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,329 +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)
{
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 [];
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextMonth);
// دریافت اطلاعات ادمین
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)
.Select(c => c.ContractingPartyId);
// دریافت کارگاه‌های مرتبط با اکانت
var workshopAccounts = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId).ToList();
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 workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x =>
((x.StartWorkDate <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate)
|| (x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth)) && workshopAccounts.Contains(x.WorkshopId)).Select(x => x.WorkshopId);
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextFirstMonth);
var nextEndMonth = Tools.FindeEndOfMonth(nextFirstMonth.ToFarsi()).ToGeorgianDateTime();
// دریافت اطلاعات ادمین
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
// اگر ادمین پیدا نشد، لیست خالی برگردان
if (adminAccount == null)
return [];
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
var contractingPartyIds = _companyContext.InstitutionContractSet.AsNoTracking()
.Where(c => c.ContractStartGr <= targetEndDate && c.ContractEndGr >= targetStartDate)
.Select(c => c.ContractingPartyId);
// دریافت کارگاه‌های مرتبط با اکانت
var workshopAccounts = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId).ToList();
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);
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// 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();
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// 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 workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
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();
// پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
.Select(x => x.WorkshopId)
.ToListAsync();
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds, targetDate, nextMonth);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds, targetStartDate,targetEndDate, nextFirstMonth,nextEndMonth);
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "false" : "true";
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "false" : "true";
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).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);
// دریافت همه 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.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));
}
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 <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
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 <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth && 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 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 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 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 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();
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;
}
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);
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);
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
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 targetDate, DateTime nextMonth)
{
var vipGroup = _companyContext.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
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 <= targetDate &&
x.leftWork.LeftWorkDate.AddDays(-1) >= targetDate &&
x.contract.ContarctStart <= targetDate &&
x.contract.ContractEnd >= targetDate
&& !vipGroup.Contains(x.leftWork.EmployeeId)
)
.Select(x => new { x.leftWork.WorkshopId, x.leftWork.EmployeeId });
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 <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth
&& !vipGroup.Contains(x.EmployeeId))
.Select(x => new { x.WorkshopId, x.EmployeeId });
.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 <= nextMonth && x.ContractEnd >= nextMonth && workshopIds.Contains(x.WorkshopIds))
.Select(x => new { x.WorkshopIds, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopIds, x.EmployeeId))
.ToHashSet();
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 <= targetDate && x.ContractEnd >= targetDate && workshopIds.Contains(x.WorkshopId))
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopId, 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 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 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 workshopsWithFullContracts = workingContractGrouping
.Where(g => g.Data.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.WorkshopId)
.ToList();
var workshopsWithFullCheckout = workingCheckoutGrouping
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.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 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 = 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 notFullyCoveredWorkshops = workshopIds.Except(fullyCoveredWorkshops);
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
.Where(x => x.Month == month && x.Year == year);
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 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();
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 adminMonthlyOverviewsWithFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.SaveChangesAsync();
}
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);
}
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();
}
await _companyContext.SaveChangesAsync();
}
}

View File

@@ -0,0 +1,14 @@
using _0_Framework.InfraStructure;
using Company.Domain.ContactUsAgg;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
public class ContactUsRepository:RepositoryBase<long,ContactUs>,IContactUsRepository
{
private readonly CompanyContext _companyContext;
public ContactUsRepository(CompanyContext companyContext) : base(companyContext)
{
_companyContext = companyContext;
}
}

View File

@@ -8,364 +8,351 @@ using CompanyManagment.App.Contracts.CustomizeWorkshopSettings.ValueObjectsViewM
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.Infrastructure;
namespace CompanyManagment.EFCore.Repository;
public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, IAuthHelper authHelper, IEmployeeRepository employeeRepository)
: RepositoryBase<long, CustomizeWorkshopSettings>(companyContext), ICustomizeWorkshopSettingsRepository
namespace CompanyManagment.EFCore.Repository
{
private readonly CompanyContext _companyContext = companyContext;
private readonly IAuthHelper _authHelper = authHelper;
private readonly IEmployeeRepository _employeeRepository = employeeRepository;
public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth)
public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, IAuthHelper authHelper, IEmployeeRepository employeeRepository)
: RepositoryBase<long, CustomizeWorkshopSettings>(companyContext), ICustomizeWorkshopSettingsRepository
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).AsSplitQuery()
.FirstOrDefault();
if (entity == null)
return new();
private readonly CompanyContext _companyContext = companyContext;
private readonly IAuthHelper _authHelper = authHelper;
private readonly IEmployeeRepository _employeeRepository = employeeRepository;
var employeeIds = entity.CustomizeWorkshopGroupSettingsCollection
.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.Select(y => y.EmployeeId)
.ToList();
var employees = _employeeRepository.GetBy(employeeIds);
return new CustomizeWorkshopSettingsViewModel()
public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth)
{
Id = entity.id,
Name = auth.WorkshopList.FirstOrDefault(w => w.Id == entity.WorkshopId)?.Name,
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = x.id,
GroupName = x.GroupName,
RollCallWorkshopEmployeesSettings = x.CustomizeWorkshopEmployeeSettingsCollection.Select(y =>
{
var employee = employees.First(e => e.Id == y.EmployeeId);
return new CustomizeWorkshopEmployeeSettingsViewModel()
{
Id = y.id,
EmployeeId = y.EmployeeId,
IsSettingChanged = y.IsSettingChanged,
IsShiftChanged = y.IsShiftChanged,
Name = $"{employee}",
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
Salary = y.Salary,
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).AsSplitQuery()
.FirstOrDefault();
if (entity == null)
return new();
};
}).ToList(),
WorkshopShiftStatus = x.WorkshopShiftStatus,
IrregularShift = x.IrregularShift,
Salary = x.Salary,
RollCallWorkshopShifts = x.CustomizeWorkshopGroupSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
MainGroup = x.MainGroup,
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.
Select(r=>new CustomizeRotatingShiftsViewModel(){StartTime = r.StartTime.ToString("HH:mm"), EndTime = r.EndTime.ToString("HH:mm")}).ToList()
}).ToList(),
};
}
public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId)
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).AsSplitQuery()
.FirstOrDefault();
if (entity == null)
return new();
return new CustomizeWorkshopSettingsViewModel()
{
Id = entity.id,
Offset = entity.EndTimeOffSet,
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = x.id,
GroupName = x.GroupName,
RollCallWorkshopEmployeesSettings = x.CustomizeWorkshopEmployeeSettingsCollection.Select(y =>
{
var employee = _employeeRepository.Get(y.EmployeeId);
return new CustomizeWorkshopEmployeeSettingsViewModel()
{
Id = y.id,
EmployeeId = y.EmployeeId,
IsSettingChanged = y.IsSettingChanged,
IsShiftChanged = y.IsShiftChanged,
Name = $"{employee?.FName} {employee?.LName}",
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
Salary = y.Salary,
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
{
StartTime = r.StartTime.ToString("HH:mm"),
EndTime = r.EndTime.ToString("HH:mm")
}).ToList(),
LeavePermittedDays = y.LeavePermittedDays,
IrregularShift = y.IrregularShift,
WorkshopShiftStatus = y.WorkshopShiftStatus
};
}).ToList(),
Salary = x.Salary,
RollCallWorkshopShifts = x.CustomizeWorkshopGroupSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
MainGroup = x.MainGroup,
WorkshopShiftStatus = x.WorkshopShiftStatus,
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
{
StartTime = r.StartTime.ToString("HH:mm"),
EndTime = r.EndTime.ToString("HH:mm")
}).ToList(),
IrregularShift = x.IrregularShift
}).ToList(),
};
}
public EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId)
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
if (entity == null)
return new();
var viewModel = new EditCustomizeWorkshopSettings()
{
FridayWork = entity.FridayWork,
FridayPay = new() { FridayPayType = entity.FridayPay.FridayPayType, Value = entity.FridayPay.Value },
LateToWork = new()
var employeeIds = entity.CustomizeWorkshopGroupSettingsCollection
.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.Select(y => y.EmployeeId)
.ToList();
var employees = _employeeRepository.GetBy(employeeIds);
return new CustomizeWorkshopSettingsViewModel()
{
LateToWorkTimeFinesVewModels = entity.LateToWork.LateToWorkTimeFines.Select(x =>
new LateToWorkTimeFineVewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.LateToWork.Value,
LateToWorkType = entity.LateToWork.LateToWorkType
},
HolidayWork = entity.HolidayWork,
FineAbsenceDeduction = new()
{
Value = entity.FineAbsenceDeduction.Value,
FineAbsenceDayOfWeekViewModels = entity.FineAbsenceDeduction.FineAbsenceDayOfWeekCollection
.Select(x => new FineAbsenceDayOfWeekViewModel() { DayOfWeek = x.DayOfWeek }).ToList(),
FineAbsenceDeductionType = entity.FineAbsenceDeduction.FineAbsenceDeductionType
},
EarlyExit = new()
{
EarlyExitTimeFinesViewModels = entity.EarlyExit.EarlyExitTimeFines.Select(x =>
new EarlyExitTimeFineViewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.EarlyExit.Value,
EarlyExitType = entity.EarlyExit.EarlyExitType
},
BonusesPay = new()
{
Value = entity.BonusesPay.Value,
BonusesPayType = entity.BonusesPay.BonusesPayType,
PaymentType = entity.BonusesPay.PaymentType
},
ShiftPay = new()
{
Value = entity.ShiftPay.Value,
ShiftPayType = entity.ShiftPay.ShiftPayType,
ShiftType = entity.ShiftPay.ShiftType
},
InsuranceDeduction = new()
{
Value = entity.InsuranceDeduction.Value,
InsuranceDeductionType = entity.InsuranceDeduction.InsuranceDeductionType
},
OverTimePay = new()
{ OverTimePayType = entity.OverTimePay.OverTimePayType, Value = entity.OverTimePay.Value },
BaseYearsPay = new()
{
BaseYearsPayType = entity.BaseYearsPay.BaseYearsPayType,
Value = entity.BaseYearsPay.Value,
PaymentType = entity.BaseYearsPay.PaymentType
},
NightWorkPay = new()
{ NightWorkingType = entity.NightWorkPay.NightWorkingType, Value = entity.NightWorkPay.Value },
LeavePay = new()
{
Value = entity.LeavePay.Value,
LeavePayType = entity.LeavePay.LeavePayType
},
MarriedAllowance = new()
{
Value = entity.MarriedAllowance.Value,
MarriedAllowanceType = entity.MarriedAllowance.MarriedAllowanceType
},
FamilyAllowance = new()
{
FamilyAllowanceType = entity.FamilyAllowance.FamilyAllowanceType,
Value = entity.FamilyAllowance.Value
},
Currency = entity.Currency,
MaxMonthDays = entity.MaxMonthDays,
Id = entity.id,
ShiftsList = entity.CustomizeWorkshopSettingsShifts.Select(x => new CustomizeWorkshopShiftViewModel()
{ EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement, StartTime = x.StartTime.ToString("HH:mm") }).ToList(),
BonusesPaysInEndOfMonth = entity.BonusesPaysInEndOfMonth,
LeavePermittedDays = entity.LeavePermittedDays,
BaseYearsPayInEndOfYear = entity.BaseYearsPayInEndOfYear,
WorkshopId = entity.WorkshopId,
WorkshopShiftStatus = entity.WorkshopShiftStatus
};
return viewModel;
}
public EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId)
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
if (entity == null)
{
return new();
}
return new()
{
ShiftsList = entity.CustomizeWorkshopSettingsShifts.Select(x => new CustomizeWorkshopShiftViewModel()
{
EndTime = x.EndTime.ToString("HH:mm"),
StartTime = x.StartTime.ToString("HH:mm"),
Placement = x.Placement
}).ToList(),
Id = entity.id,
WorkshopId = entity.WorkshopId,
WorkshopShiftStatus = entity.WorkshopShiftStatus,
FridayWork = entity.FridayWork,
HolidayWork = entity.HolidayWork
};
}
public List<ChangedGroupedViewModel> GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId)
{
var result = from groupSetting in _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery()
where groupSetting.IsShiftChange // Filter parent tables where isChange is true
join employeeSettings in _companyContext.CustomizeWorkshopEmployeeSettings on groupSetting.id equals employeeSettings.CustomizeWorkshopGroupSettingId
where employeeSettings.IsShiftChanged// Filter child tables where isChange is true
join employee in _companyContext.Employees on employeeSettings.EmployeeId equals employee.id
group new { employee.FullName, groupSetting.GroupName } by groupSetting.id into grouped
select new ChangedGroupedViewModel
{
GroupName = grouped.First().GroupName,
EmployeeName = grouped.Select(e => e.FullName).ToList()
};
return result.ToList();
}
public CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId)
{
var customizeWorkshopSettings = _companyContext.CustomizeWorkshopSettings
.AsNoTracking().AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.Select(x => new CustomizeWorkshopSettingsViewModel()
{
Id = x.id,
WorkshopShiftStatus = x.WorkshopShiftStatus,
GroupSettings = x.CustomizeWorkshopGroupSettingsCollection.Select(g =>
Id = entity.id,
Name = auth.WorkshopList.FirstOrDefault(w => w.Id == entity.WorkshopId)?.Name,
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = g.id,
IrregularShift = g.IrregularShift,
WorkshopShiftStatus = g.WorkshopShiftStatus,
GroupName = g.GroupName,
MainGroup = g.MainGroup,
RollCallWorkshopShifts = g.CustomizeWorkshopGroupSettingsShifts.Select(s =>
Id = x.id,
GroupName = x.GroupName,
WorkshopShiftStatus = x.WorkshopShiftStatus,
IrregularShift = x.IrregularShift,
Salary = x.Salary,
RollCallWorkshopShifts = x.CustomizeWorkshopGroupSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
StartTime = s.StartTime.ToString("HH:mm"),
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
}).ToList(),
BreakTime = g.BreakTime,
HolidayWork = g.HolidayWork,
FridayWork = g.FridayWork,
CustomizeRotatingShiftsViewModels = g.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel()
{
EndTime = r.EndTime.ToString("HH:mm"),
StartTime = r.StartTime.ToString("HH:mm")
}).ToList()
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
MainGroup = x.MainGroup,
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.
Select(r=>new CustomizeRotatingShiftsViewModel(){StartTime = r.StartTime.ToString("HH:mm"), EndTime = r.EndTime.ToString("HH:mm")}).ToList()
}).ToList(),
}).FirstOrDefault();
return customizeWorkshopSettings;
}
public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByWorkshopIdEmployeeId(long workshopId, long employeeId)
{
var employee = _companyContext.CustomizeWorkshopSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.WorkshopId == workshopId)?.CustomizeWorkshopGroupSettingsCollection.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.EmployeeId == employeeId);
if (employee == null)
return new();
var employeeName = _companyContext.Employees.Select(x => new { x.FullName, x.id })
.FirstOrDefault(x => x.id == employee.EmployeeId);
return new CustomizeWorkshopEmployeeSettingsViewModel()
};
}
public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId)
{
Id = employee.id,
EmployeeId = employee.EmployeeId,
IsSettingChanged = employee.IsSettingChanged,
IsShiftChanged = employee.IsShiftChanged,
Name = employeeName?.FullName,
RollCallWorkshopShifts = employee.CustomizeWorkshopEmployeeSettingsShifts.Select(x =>
new CustomizeWorkshopShiftViewModel()
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).AsSplitQuery()
.FirstOrDefault();
if (entity == null)
return new();
return new CustomizeWorkshopSettingsViewModel()
{
Id = entity.id,
Offset = entity.EndTimeOffSet,
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = x.id,
GroupName = x.GroupName,
RollCallWorkshopEmployeesSettings = x.CustomizeWorkshopEmployeeSettingsCollection.Select(y =>
{
var employee = _employeeRepository.Get(y.EmployeeId);
return new CustomizeWorkshopEmployeeSettingsViewModel()
{
Id = y.id,
EmployeeId = y.EmployeeId,
IsSettingChanged = y.IsSettingChanged,
IsShiftChanged = y.IsShiftChanged,
Name = $"{employee?.FName} {employee?.LName}",
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
Salary = y.Salary,
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
{
StartTime = r.StartTime.ToString("HH:mm"),
EndTime = r.EndTime.ToString("HH:mm")
}).ToList(),
LeavePermittedDays = y.LeavePermittedDays,
IrregularShift = y.IrregularShift,
WorkshopShiftStatus = y.WorkshopShiftStatus
};
}).ToList(),
Salary = x.Salary,
RollCallWorkshopShifts = x.CustomizeWorkshopGroupSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
StartTime = s.StartTime.ToString("HH:mm")
}).ToList(),
MainGroup = x.MainGroup,
WorkshopShiftStatus = x.WorkshopShiftStatus,
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r=>new CustomizeRotatingShiftsViewModel
{
StartTime = r.StartTime.ToString("HH:mm"),
EndTime = r.EndTime.ToString("HH:mm")
}).ToList(),
IrregularShift = x.IrregularShift
}).ToList(),
};
}
public EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId)
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
if (entity == null)
return new();
var viewModel = new EditCustomizeWorkshopSettings()
{
FridayWork = entity.FridayWork,
FridayPay = new() { FridayPayType = entity.FridayPay.FridayPayType, Value = entity.FridayPay.Value },
LateToWork = new()
{
LateToWorkTimeFinesVewModels = entity.LateToWork.LateToWorkTimeFines.Select(x =>
new LateToWorkTimeFineVewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.LateToWork.Value,
LateToWorkType = entity.LateToWork.LateToWorkType
},
HolidayWork = entity.HolidayWork,
FineAbsenceDeduction = new()
{
Value = entity.FineAbsenceDeduction.Value,
FineAbsenceDayOfWeekViewModels = entity.FineAbsenceDeduction.FineAbsenceDayOfWeekCollection
.Select(x => new FineAbsenceDayOfWeekViewModel() { DayOfWeek = x.DayOfWeek }).ToList(),
FineAbsenceDeductionType = entity.FineAbsenceDeduction.FineAbsenceDeductionType
},
EarlyExit = new()
{
EarlyExitTimeFinesViewModels = entity.EarlyExit.EarlyExitTimeFines.Select(x =>
new EarlyExitTimeFineViewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.EarlyExit.Value,
EarlyExitType = entity.EarlyExit.EarlyExitType
},
BonusesPay = new()
{
Value = entity.BonusesPay.Value,
BonusesPayType = entity.BonusesPay.BonusesPayType,
PaymentType = entity.BonusesPay.PaymentType
},
ShiftPay = new()
{
Value = entity.ShiftPay.Value,
ShiftPayType = entity.ShiftPay.ShiftPayType,
ShiftType = entity.ShiftPay.ShiftType
},
InsuranceDeduction = new()
{
Value = entity.InsuranceDeduction.Value,
InsuranceDeductionType = entity.InsuranceDeduction.InsuranceDeductionType
},
OverTimePay = new()
{ OverTimePayType = entity.OverTimePay.OverTimePayType, Value = entity.OverTimePay.Value },
BaseYearsPay = new()
{
BaseYearsPayType = entity.BaseYearsPay.BaseYearsPayType,
Value = entity.BaseYearsPay.Value,
PaymentType = entity.BaseYearsPay.PaymentType
},
NightWorkPay = new()
{ NightWorkingType = entity.NightWorkPay.NightWorkingType, Value = entity.NightWorkPay.Value },
LeavePay = new()
{
Value = entity.LeavePay.Value,
LeavePayType = entity.LeavePay.LeavePayType
},
MarriedAllowance = new()
{
Value = entity.MarriedAllowance.Value,
MarriedAllowanceType = entity.MarriedAllowance.MarriedAllowanceType
},
FamilyAllowance = new()
{
FamilyAllowanceType = entity.FamilyAllowance.FamilyAllowanceType,
Value = entity.FamilyAllowance.Value
},
Currency = entity.Currency,
MaxMonthDays = entity.MaxMonthDays,
Id = entity.id,
ShiftsList = entity.CustomizeWorkshopSettingsShifts.Select(x => new CustomizeWorkshopShiftViewModel()
{ EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement, StartTime = x.StartTime.ToString("HH:mm") }).ToList(),
BonusesPaysInEndOfMonth = entity.BonusesPaysInEndOfMonth,
LeavePermittedDays = entity.LeavePermittedDays,
BaseYearsPayInEndOfYear = entity.BaseYearsPayInEndOfYear,
WorkshopId = entity.WorkshopId,
WorkshopShiftStatus = entity.WorkshopShiftStatus
};
return viewModel;
}
public CustomizeWorkshopSettings GetBy(long workshopId)
{
return _companyContext.CustomizeWorkshopSettings.FirstOrDefault(x => x.WorkshopId == workshopId);
}
public EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId)
{
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
if (entity == null)
{
return new();
}
return new()
{
ShiftsList = entity.CustomizeWorkshopSettingsShifts.Select(x => new CustomizeWorkshopShiftViewModel()
{
EndTime = x.EndTime.ToString("HH:mm"),
Placement = x.Placement,
StartTime = x.StartTime.ToString("HH:mm")
StartTime = x.StartTime.ToString("HH:mm"),
Placement = x.Placement
}).ToList(),
Salary = employee.Salary
};
}
Id = entity.id,
WorkshopId = entity.WorkshopId,
WorkshopShiftStatus = entity.WorkshopShiftStatus,
FridayWork = entity.FridayWork,
HolidayWork = entity.HolidayWork
#region Pooya
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsWithMonthlySalary(long workshopId)
{
var query = _companyContext.CustomizeWorkshopGroupSettings.Where(x => x.MainGroup == false).Include(x => x)
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection).Where(x => x.CustomizeWorkshopEmployeeSettingsCollection.Any(y =>
};
}
public List<ChangedGroupedViewModel> GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId)
{
var result = from groupSetting in _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery()
where groupSetting.IsShiftChange // Filter parent tables where isChange is true
join employeeSettings in _companyContext.CustomizeWorkshopEmployeeSettings on groupSetting.id equals employeeSettings.CustomizeWorkshopGroupSettingId
where employeeSettings.IsShiftChanged// Filter child tables where isChange is true
join employee in _companyContext.Employees on employeeSettings.EmployeeId equals employee.id
group new { employee.FullName, groupSetting.GroupName } by groupSetting.id into grouped
select new ChangedGroupedViewModel
{
GroupName = grouped.First().GroupName,
EmployeeName = grouped.Select(e => e.FullName).ToList()
};
return result.ToList();
}
public CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId)
{
var customizeWorkshopSettings = _companyContext.CustomizeWorkshopSettings
.AsNoTracking().AsSplitQuery().Where(x => x.WorkshopId == workshopId)
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.Select(x => new CustomizeWorkshopSettingsViewModel()
{
Id = x.id,
WorkshopShiftStatus = x.WorkshopShiftStatus,
GroupSettings = x.CustomizeWorkshopGroupSettingsCollection.Select(g =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = g.id,
IrregularShift = g.IrregularShift,
WorkshopShiftStatus = g.WorkshopShiftStatus,
GroupName = g.GroupName,
MainGroup = g.MainGroup,
Salary = g.Salary,
SalaryStr = g.Salary.ToMoney(),
LeavePermitted = g.LeavePermittedDays,
RollCallWorkshopShifts = g.CustomizeWorkshopGroupSettingsShifts.Select(s =>
new CustomizeWorkshopShiftViewModel()
{
StartTime = s.StartTime.ToString("HH:mm"),
EndTime = s.EndTime.ToString("HH:mm"),
Placement = s.Placement,
}).ToList(),
BreakTime = g.BreakTime,
HolidayWork = g.HolidayWork,
FridayWork = g.FridayWork,
CustomizeRotatingShiftsViewModels = g.CustomizeRotatingShifts.Select(r=>new CustomizeRotatingShiftsViewModel()
{
EndTime = r.EndTime.ToString("HH:mm"),
StartTime= r.StartTime.ToString("HH:mm")
}).ToList()
}).ToList(),
}).FirstOrDefault();
return customizeWorkshopSettings;
}
public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByWorkshopIdEmployeeId(long workshopId, long employeeId)
{
var employee = _companyContext.CustomizeWorkshopSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.WorkshopId == workshopId)?.CustomizeWorkshopGroupSettingsCollection.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.EmployeeId == employeeId);
if (employee == null)
return new();
var employeeName = _companyContext.Employees.Select(x => new { x.FullName, x.id })
.FirstOrDefault(x => x.id == employee.EmployeeId);
return new CustomizeWorkshopEmployeeSettingsViewModel()
{
Id = employee.id,
EmployeeId = employee.EmployeeId,
IsSettingChanged = employee.IsSettingChanged,
IsShiftChanged = employee.IsShiftChanged,
Name = employeeName?.FullName,
RollCallWorkshopShifts = employee.CustomizeWorkshopEmployeeSettingsShifts.Select(x =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = x.EndTime.ToString("HH:mm"),
Placement = x.Placement,
StartTime = x.StartTime.ToString("HH:mm")
}).ToList(),
Salary = employee.Salary
};
}
#region Pooya
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsWithMonthlySalary(long workshopId)
{
var query = _companyContext.CustomizeWorkshopGroupSettings.Where(x => x.MainGroup == false).Include(x => x)
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection).Where(x => x.CustomizeWorkshopEmployeeSettingsCollection.Any(y =>
y.WorkshopId == workshopId)).SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.Where(x => x.Salary > 0).Select(x =>
.Where(x => x.Salary > 0).Select(x =>
new CustomizeWorkshopEmployeeSettingsViewModel()
{
WorkshopShiftStatus = x.WorkshopShiftStatus,
@@ -374,31 +361,26 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
EmployeeId = x.EmployeeId,
BreakTime = x.BreakTime
});
return query.ToList();
}
return query.ToList();
}
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByWorkshopId(long workshopId)
{
return _companyContext.CustomizeWorkshopSettings.AsNoTracking().Where(x => x.WorkshopId == workshopId).Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).SelectMany(x => x.CustomizeWorkshopGroupSettingsCollection
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByWorkshopId(long workshopId)
{
return _companyContext.CustomizeWorkshopSettings.AsNoTracking().Where(x => x.WorkshopId == workshopId).Include(x => x.CustomizeWorkshopGroupSettingsCollection)
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).SelectMany(x => x.CustomizeWorkshopGroupSettingsCollection
.SelectMany(y => y.CustomizeWorkshopEmployeeSettingsCollection))
.Select(x => new CustomizeWorkshopEmployeeSettingsViewModel
{
BreakTime = x.BreakTime,
IsShiftChanged = x.IsShiftChanged,
IsSettingChanged = x.IsSettingChanged,
EmployeeId = x.EmployeeId,
Id = x.id,
Salary = x.Salary,
GroupSettingsId = x.CustomizeWorkshopGroupSettingId
}).ToList();
}
.Select(x => new CustomizeWorkshopEmployeeSettingsViewModel
{
BreakTime = x.BreakTime,
IsShiftChanged = x.IsShiftChanged,
IsSettingChanged = x.IsSettingChanged,
EmployeeId = x.EmployeeId,
Id = x.id,
Salary = x.Salary,
GroupSettingsId = x.CustomizeWorkshopGroupSettingId
}).ToList();
}
public CustomizeWorkshopSettings GetBy(long workshopId)
{
return _companyContext.CustomizeWorkshopSettings.AsSplitQuery()
.FirstOrDefault(x => x.WorkshopId == workshopId);
#endregion
}
#endregion
}

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

@@ -1,10 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using AccountMangement.Infrastructure.EFCore;
using Company.Domain.EmployeeAgg;
using Company.Domain.EmployeeChildrenAgg;
using Company.Domain.EmployeeInsurancListDataAgg;
@@ -16,6 +20,7 @@ using CompanyManagment.App.Contracts.EmployeeInsurancListData;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.InsuranceWorkshopInfo;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Identity.Client;
using PersianTools.Core;
@@ -32,7 +37,10 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
private readonly IAuthHelper _authHelper;
private readonly IPersonalContractingPartyApp _contractingPartyApp;
private readonly IInsuranceYearlySalaryRepository _insuranceYearlySalaryRepository;
public InsuranceListRepository(CompanyContext context, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceListWorkshopRepository insuranceListWorkshopRepository , IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IAuthHelper authHelper, IPersonalContractingPartyApp contractingPartyApp, IInsuranceYearlySalaryRepository insuranceYearlySalaryRepository) : base(context)
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly AccountContext _accountContext;
public InsuranceListRepository(CompanyContext context, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceListWorkshopRepository insuranceListWorkshopRepository, IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IAuthHelper authHelper, IPersonalContractingPartyApp contractingPartyApp, IInsuranceYearlySalaryRepository insuranceYearlySalaryRepository, IWebHostEnvironment webHostEnvironment, AccountContext accountContext) : base(context)
{
_context = context;
_employeeInsurancListDataRepository = employeeInsurancListDataRepository;
@@ -41,20 +49,22 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
_authHelper = authHelper;
_contractingPartyApp = contractingPartyApp;
_insuranceYearlySalaryRepository = insuranceYearlySalaryRepository;
_webHostEnvironment = webHostEnvironment;
_accountContext = accountContext;
}
public OperationResult CreateInsuranceListworkshop(long id, List<long> workshopIds)
{
var operation = new OperationResult();
//try
//{
var list= new List<InsuranceListWorkshop>();
var list = new List<InsuranceListWorkshop>();
foreach (var item in workshopIds)
{
list.Add(new InsuranceListWorkshop()
{
WorkshopId =item,
InsurancListId= id
WorkshopId = item,
InsurancListId = id
});
}
@@ -76,11 +86,11 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
public OperationResult CreateInsuranceListworkshopInfo(CreateInsuranceWorkshopInfo command)
{
var operation = new OperationResult();
var obj = _context.InsuranceWorkshopInformationSet.Where(x=>x.WorkshopId== command.WorkshopId).FirstOrDefault();
var obj = _context.InsuranceWorkshopInformationSet.Where(x => x.WorkshopId == command.WorkshopId).FirstOrDefault();
if (obj != null)
{
obj.Edit(command.WorkshopName, command.InsuranceCode, command.AgreementNumber, command.EmployerName, command.Address,command.ListNumber);
obj.Edit(command.WorkshopName, command.InsuranceCode, command.AgreementNumber, command.EmployerName, command.Address, command.ListNumber);
_context.SaveChanges();
}
else
@@ -91,7 +101,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
_context.SaveChanges();
}
return operation;
}
@@ -103,9 +113,9 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
try
{
var insuranceListObj = Get(command.Id);
insuranceListObj.Edit(command.SumOfEmployees,command.SumOfWorkingDays,command.SumOfSalaries,command.SumOfBenefitsIncluded,command.Included,command.IncludedAndNotIncluded,command.InsuredShare,
command.EmployerShare,command.UnEmploymentInsurance,command.DifficultJobsInsuranc,command.StartDate,command.SumOfDailyWage,command.SumOfBaseYears,command.SumOfMarriedAllowance, command.ConfirmSentlist);
insuranceListObj.Edit(command.SumOfEmployees, command.SumOfWorkingDays, command.SumOfSalaries, command.SumOfBenefitsIncluded, command.Included, command.IncludedAndNotIncluded, command.InsuredShare,
command.EmployerShare, command.UnEmploymentInsurance, command.DifficultJobsInsuranc, command.StartDate, command.SumOfDailyWage, command.SumOfBaseYears, command.SumOfMarriedAllowance, command.ConfirmSentlist);
var id = insuranceListObj.id;
if (command.EmployeeInsurancListDataList != null && command.EmployeeInsurancListDataList.Count > 0)
{
@@ -121,14 +131,14 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
item.BenefitsIncludedContinuous,
item.BenefitsIncludedNonContinuous,
item.InsuranceShare, item.StartWorkDate,
item.LeftWorkDate, item.JobId,item.IncludeStatus,item.BaseYears,item.MarriedAllowance,item.OverTimePay,item.FamilyAllowance);
item.LeftWorkDate, item.JobId, item.IncludeStatus, item.BaseYears, item.MarriedAllowance, item.OverTimePay, item.FamilyAllowance);
_employeeInsurancListDataRepository.Create(employeeInsurancListData);
}
else
{
var employeeInsurancListDataObj = _employeeInsurancListDataRepository.Get(item.EmployeeInsurancListDataId);
employeeInsurancListDataObj.Edit(item.WorkingDays,item.DailyWage,item.MonthlySalary,item.MonthlyBenefits,item .MonthlyBenefitsIncluded,item.BenefitsIncludedContinuous,
item.BenefitsIncludedNonContinuous,item.InsuranceShare,item.StartWorkDate,item.LeftWorkDate,item.JobId,item.IncludeStatus,item.BaseYears,item.MarriedAllowance,item.OverTimePay,item.FamilyAllowance);
employeeInsurancListDataObj.Edit(item.WorkingDays, item.DailyWage, item.MonthlySalary, item.MonthlyBenefits, item.MonthlyBenefitsIncluded, item.BenefitsIncludedContinuous,
item.BenefitsIncludedNonContinuous, item.InsuranceShare, item.StartWorkDate, item.LeftWorkDate, item.JobId, item.IncludeStatus, item.BaseYears, item.MarriedAllowance, item.OverTimePay, item.FamilyAllowance);
}
}
_employeeInsurancListDataRepository.SaveChanges();
@@ -210,7 +220,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
// نام کارفرما
EmployerName = x.EmployerName,
//آدرس کارگاه
Address = x.Address,
Address = x.Address,
ListNumber = x.ListNumber,
}).FirstOrDefault();
#endregion
@@ -234,7 +244,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//مزایای ماهانه
employeeInsurancListData.MonthlyBenefits = item.MonthlyBenefits;
//دستمزد و مزایای ماهانه مشمول
employeeInsurancListData.MonthlyBenefitsIncluded =item.MonthlyBenefitsIncluded;
employeeInsurancListData.MonthlyBenefitsIncluded = item.MonthlyBenefitsIncluded;
// مزایای مشمول و غیر مشمول
employeeInsurancListData.BenefitsIncludedContinuous = item.BenefitsIncludedContinuous;
//مزایای مشمول غیر مستمر
@@ -252,8 +262,8 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
employeeInsurancListData.JobName = job != null ? job.JobName : string.Empty; ;
employeeInsurancListData.JobCode = job != null ? job.JobCode : string.Empty; ;
employeeInsurancListData.StrStartWorkDate = item.StartWorkDate.ToFarsi();
if(item.LeftWorkDate!=null)
if (item.LeftWorkDate != null)
employeeInsurancListData.StrLeftWorkDate = item.LeftWorkDate.ToFarsi();
@@ -266,7 +276,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
#endregion
#region WorkshopIds
var workshopIds = _context.InsuranceListWorkshopSet.Where(x=>x.InsurancListId==id).Select(x => x.WorkshopId).ToList();
var workshopIds = _context.InsuranceListWorkshopSet.Where(x => x.InsurancListId == id).Select(x => x.WorkshopId).ToList();
#endregion
#region InsuranceEmployeeInformation
@@ -286,7 +296,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
employeeDetails.DateOfBirthGr = item.DateOfBirth;
employeeDetails.DateOfIssueGr = item.DateOfIssue;
employeeDetails.DateOfBirth = item.DateOfBirth.ToFarsi();
employeeDetails.DateOfIssue = ((item.DateOfIssue.ToFarsi())=="1300/10/11")?"": item.DateOfIssue.ToFarsi();
employeeDetails.DateOfIssue = ((item.DateOfIssue.ToFarsi()) == "1300/10/11") ? "" : item.DateOfIssue.ToFarsi();
employeeDetails.PlaceOfIssue = item.PlaceOfIssue;
employeeDetails.NationalCode = item.NationalCode;
//employeeDetails.Nationality = item.Nationality;
@@ -329,7 +339,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
public List<InsuranceListViewModel> OptimizedSearch(InsuranceListSearchModel searchModel)
{
var acountId = _authHelper.CurrentAccountId();
var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId).Select(x => x.WorkshopId);
@@ -380,7 +390,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
result => result.workshop.id,
employer => employer.WorkshopId,
(result, employer) => new { result.insurance, result.workshop, employer })
.Select(result => new InsuranceListViewModel
.Select(result => new InsuranceListViewModel
{
Id = result.insurance.id,
Year = result.insurance.Year,
@@ -402,9 +412,27 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
.Where(p => p.Employers.Any(e => e.id == result.employer.First().EmployerId))
.Select(p => p.IsBlock)
.FirstOrDefault(),
EmployerId = result.employer.First().EmployerId
EmployerId = result.employer.First().EmployerId,
DebtDone = result.insurance.Debt.IsDone,
EmployerApproved = result.insurance.EmployerApproval.IsDone,
InspectionDone = result.insurance.Inspection.IsDone
});
query = searchModel.Status switch
{
InsuranceListSearchStatus.NotStarted => query.Where(x =>
!x.DebtDone && !x.EmployerApproved && !x.InspectionDone && !x.ConfirmSentlist),
InsuranceListSearchStatus.InProgress => query.Where(x =>
(x.DebtDone || x.EmployerApproved || x.InspectionDone)&& !(x.DebtDone && x.EmployerApproved && x.InspectionDone) && !x.ConfirmSentlist),
InsuranceListSearchStatus.ReadyToSendList => query.Where(x =>
x.DebtDone && x.EmployerApproved && x.InspectionDone && !x.ConfirmSentlist),
InsuranceListSearchStatus.Done => query.Where(x => x.ConfirmSentlist),
_ => query
};
if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0" && !string.IsNullOrEmpty(searchModel.Month) && searchModel.Month != "0")
query = query.Where(x => x.Year == searchModel.Year && x.Month == searchModel.Month).OrderByDescending(x => x.Id);
@@ -456,7 +484,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//var testquery = query.Where(x => x.Year == searchModel.Year).AsEnumerable();
return query.ToList();
return query.Skip(searchModel.PageIndex).Take(30).ToList();
}
public List<InsuranceListViewModel> Search(InsuranceListSearchModel searchModel)
{
@@ -465,9 +493,9 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var acountID = _authHelper.CurrentAccountId();
var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountID).Select(x => x.WorkshopId).ToList();
List<InsuranceListViewModel> list = new List<InsuranceListViewModel>();
var query = _context.InsuranceListSet.Where(x=> workshopIds.Contains(x.WorkshopId)).ToList();
var query = _context.InsuranceListSet.Where(x => workshopIds.Contains(x.WorkshopId)).ToList();
var insuranceWorkshopInformationList = _context.InsuranceWorkshopInformationSet.Where(u => workshopIds.Contains(u.WorkshopId));
var workshopList = _context.Workshops.Where(u => workshopIds.Contains(u.id));
var workshopList = _context.Workshops.Where(u => workshopIds.Contains(u.id));
foreach (var item in query)
{
@@ -475,7 +503,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var workshop = workshopList.FirstOrDefault(u => u.id == item.WorkshopId);
var employerId = _context.WorkshopEmployers.Where(x => x.WorkshopId == item.WorkshopId)
.Select(x => x.EmployerId).FirstOrDefault();
string typeOfInsuranceSend = "";
if (workshop.TypeOfInsuranceSend == "NormalList")
{
@@ -489,20 +517,20 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
{
typeOfInsuranceSend = "خانوادگی";
}
var insuranceListViewModel =new InsuranceListViewModel()
var insuranceListViewModel = new InsuranceListViewModel()
{
Id = item.id,
Year = item.Year,
Month = item.Month,
MonthNumber = item.Month,
WorkShopCode = insuranceWorkshopInformation==null? workshop.InsuranceCode: insuranceWorkshopInformation.InsuranceCode,
WorkShopCode = insuranceWorkshopInformation == null ? workshop.InsuranceCode : insuranceWorkshopInformation.InsuranceCode,
WorkShopName = insuranceWorkshopInformation == null ? workshop.WorkshopName : insuranceWorkshopInformation.WorkshopName,
WorkShopId = workshop.id ,
WorkShopId = workshop.id,
TypeOfInsuranceSend = typeOfInsuranceSend,
FixedSalary = workshop.FixedSalary,
StrFixedSalary = workshop.FixedSalary?"دارد":"ندارد",
EmployerName = insuranceWorkshopInformation == null? workshop.WorkshopFullName: insuranceWorkshopInformation.EmployerName,
StrFixedSalary = workshop.FixedSalary ? "دارد" : "ندارد",
EmployerName = insuranceWorkshopInformation == null ? workshop.WorkshopFullName : insuranceWorkshopInformation.EmployerName,
Branch = "",
City = "",
ConfirmSentlist = item.ConfirmSentlist,
@@ -530,7 +558,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
list = list.Where(x => x.WorkShopCode == searchModel.WorkShopCode).OrderByDescending(x => x.Year).OrderByDescending(x => x.Month).ThenByDescending(x => x.EmployerName).ToList();
if (!string.IsNullOrEmpty(searchModel.WorkShopName))
list = list.Where(x => x.WorkShopName.Contains(searchModel.WorkShopName) ).OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month).ToList();
list = list.Where(x => x.WorkShopName.Contains(searchModel.WorkShopName)).OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month).ToList();
if (searchModel.WorkshopId > 0)
@@ -553,7 +581,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
list = list.Where(x => x.EmployerName.Contains(searchModel.EmployerName)).OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month).ToList();
if (searchModel.FixedSalary!=null)
if (searchModel.FixedSalary != null)
list = list.Where(x => x.FixedSalary == searchModel.FixedSalary).ToList();
if (!string.IsNullOrEmpty(searchModel.TypeOfInsuranceSend) && searchModel.TypeOfInsuranceSend != "0")
@@ -574,7 +602,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
OperationResult result = new OperationResult();
using (var transaction = _context.Database.BeginTransaction())
{
try
{
//var employeeInsurancList= _context.EmployeeInsurancListDataSet.Where(x => x.InsuranceListId == id).ToList();
@@ -584,10 +612,10 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//var insuranceListWorkshopList = _context.InsuranceListWorkshopSet.Where(x => x.InsurancListId == id).ToList();
//if (insuranceListWorkshopList != null && insuranceListWorkshopList.Count > 0)
_insuranceListWorkshopRepository.RemoveRange(id);
var insuranceListObj = _context.InsuranceListSet.Where(x => x.id == id).FirstOrDefault();
if(insuranceListObj!=null)
if (insuranceListObj != null)
Remove(insuranceListObj);
SaveChanges();
@@ -606,11 +634,11 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
return result;
}
/// <summary>
/// ایجاد لیست بیمه
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
/// <summary>
/// ایجاد لیست بیمه
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public OperationResult CreateInsuranceList(CreateInsuranceList command)
{
OperationResult result = new OperationResult();
@@ -625,7 +653,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
command.InsuredShare,
command.EmployerShare, command.UnEmploymentInsurance, command.DifficultJobsInsuranc,
command.StartDate,
command.EndDate, command.SumOfDailyWage,command.SumOfBaseYears,command.SumOfMarriedAllowance);
command.EndDate, command.SumOfDailyWage, command.SumOfBaseYears, command.SumOfMarriedAllowance);
Create(insuranceListObj);
SaveChanges();
var id = insuranceListObj.id;
@@ -641,10 +669,11 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
item.BenefitsIncludedContinuous,
item.BenefitsIncludedNonContinuous,
item.InsuranceShare, item.StartWorkDate,
item.LeftWorkDate, item.JobId,item.IncludeStatus,item.BaseYears,item.MarriedAllowance,item.OverTimePay,item.FamilyAllowance);
item.LeftWorkDate, item.JobId, item.IncludeStatus, item.BaseYears, item.MarriedAllowance, item.OverTimePay, item.FamilyAllowance);
_employeeInsurancListDataRepository.Create(employeeInsurancListData);
}_employeeInsurancListDataRepository.SaveChanges();
}
_employeeInsurancListDataRepository.SaveChanges();
}
if (command.WorkshopIds != null && command.WorkshopIds.Count > 0)
@@ -831,10 +860,10 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
editInsuranceList.WorkshopIds = workshopIds;
return editInsuranceList;
}
public MainEmployeeDetailsViewModel SearchEmployeeListForEditByInsuranceListId(EmployeeForEditInsuranceListSearchModel searchModel )
public MainEmployeeDetailsViewModel SearchEmployeeListForEditByInsuranceListId(EmployeeForEditInsuranceListSearchModel searchModel)
{
var employeeDetailsViewModel = new MainEmployeeDetailsViewModel();
@@ -845,7 +874,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
{
var leftWorkInsurance = _context.LeftWorkInsuranceList
.Where(i => i.EmployeeId == item.EmployeeId && i.WorkshopId == searchModel.WorkshopId)
.AsNoTracking().OrderByDescending(x=>x.id).FirstOrDefault();
.AsNoTracking().OrderByDescending(x => x.id).FirstOrDefault();
var job = _context.Jobs.Where(i => i.id == item.JobId).AsNoTracking().FirstOrDefault();
var employeeInsurancListData = new EmployeeInsurancListDataViewModel();
employeeInsurancListData.EmployeeInsurancListDataId = item.id;
@@ -866,7 +895,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//// مزایای ماهیانه مشمول
employeeInsurancListData.BenefitsIncludedNonContinuous = item.BenefitsIncludedNonContinuous;
//// حقوق و مزایای ماهیانه مشمول و غیر مشمول **
employeeInsurancListData.IncludedAndNotIncluded = item.BenefitsIncludedContinuous;
employeeInsurancListData.IncludedAndNotIncluded = item.BenefitsIncludedContinuous;
employeeInsurancListData.BaseYears = item.BaseYears;
employeeInsurancListData.MarriedAllowance = item.MarriedAllowance;
@@ -875,7 +904,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//سهم بیمه حق کارگر
employeeInsurancListData.InsuranceShare = item.InsuranceShare;
// تاریخ شروع به کار
employeeInsurancListData.StartWorkDate =item.StartWorkDate;
employeeInsurancListData.StartWorkDate = item.StartWorkDate;
//تاریخ ترک کار
employeeInsurancListData.LeftWorkDate = item.LeftWorkDate;
// آی دی شغل
@@ -883,7 +912,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
employeeInsurancListData.JobName = job != null ? job.JobName : string.Empty;
employeeInsurancListData.JobCode = job != null ? job.JobCode : string.Empty;
employeeInsurancListData.StrStartWorkDate = item.StartWorkDate.ToFarsi();
if (item.LeftWorkDate != null)
employeeInsurancListData.StrLeftWorkDate = item.LeftWorkDate.ToFarsi();
@@ -893,7 +922,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//ممکن است کسی شامل مزایا باشد و در آن ماه برایش یا مزد روزانه رد نشده باشد
// باید با یک فیلد چک شود
//
if (leftWorkInsurance != null && ((leftWorkInsurance.IncludeStatus!=leftWorkInsurance.IncludeStatus ) || ((leftWorkInsurance.LeftWorkDate!=item.LeftWorkDate)||(leftWorkInsurance.StartWorkDate != item.StartWorkDate ) ||(leftWorkInsurance.JobId != item.JobId))))
if (leftWorkInsurance != null && ((leftWorkInsurance.IncludeStatus != leftWorkInsurance.IncludeStatus) || ((leftWorkInsurance.LeftWorkDate != item.LeftWorkDate) || (leftWorkInsurance.StartWorkDate != item.StartWorkDate) || (leftWorkInsurance.JobId != item.JobId))))
{
employeeInsurancListData.HasConfilictLeftWork = true;
if (leftWorkInsurance.LeftWorkDate != null)
@@ -924,7 +953,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var employeeDetailsForInsuranceList = new List<EmployeeDetailsForInsuranceListViewModel>();
foreach (var item in insuranceEmployeeInformationList)
{
var employeeObject = _context.Employees.Where(x=>x.id==item.EmployeeId)?.FirstOrDefault();
var employeeObject = _context.Employees.Where(x => x.id == item.EmployeeId)?.FirstOrDefault();
var employeeInsurancListData = employeeInsurancListDataViewModelList.Where(x => x.EmployeeId == item.EmployeeId)?.FirstOrDefault();
var employeeDetails = new EmployeeDetailsForInsuranceListViewModel();
employeeDetails.EmployeeId = item.EmployeeId;
@@ -993,13 +1022,13 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
public OperationResult ConfirmInsuranceList(long id)
{
OperationResult result = new OperationResult();
try
{
var insuranceListObj = Get(id);
insuranceListObj.Edit(insuranceListObj.SumOfEmployees, insuranceListObj.SumOfWorkingDays, insuranceListObj.SumOfSalaries, insuranceListObj.SumOfBenefitsIncluded, insuranceListObj.Included, insuranceListObj.IncludedAndNotIncluded, insuranceListObj.InsuredShare,
insuranceListObj.EmployerShare, insuranceListObj.UnEmploymentInsurance, insuranceListObj.DifficultJobsInsuranc, insuranceListObj.StartDate, insuranceListObj.SumOfDailyWage,insuranceListObj.SumOfBaseYears,insuranceListObj.SumOfMarriedAllowance,true);
insuranceListObj.EmployerShare, insuranceListObj.UnEmploymentInsurance, insuranceListObj.DifficultJobsInsuranc, insuranceListObj.StartDate, insuranceListObj.SumOfDailyWage, insuranceListObj.SumOfBaseYears, insuranceListObj.SumOfMarriedAllowance, true);
SaveChanges();
@@ -1009,9 +1038,9 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
{
result.Message = "تایید ارسال لیست بیمه با موفقیت انجام شد";
}
return result;
}
@@ -1020,7 +1049,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
{
var insuranceListViewModel = new InsuranceListViewModel();
var insuranceList = _context.InsuranceListSet.Where(x => x.WorkshopId == workshopId && x.Year == year).OrderByDescending(x=>x.id)?.FirstOrDefault();
var insuranceList = _context.InsuranceListSet.Where(x => x.WorkshopId == workshopId && x.Year == year).OrderByDescending(x => x.id)?.FirstOrDefault();
if (insuranceList != null)
{
@@ -1031,7 +1060,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
insuranceListViewModel.WorkShopId = insuranceList.WorkshopId;
insuranceListViewModel.ConfirmSentlist = insuranceList.ConfirmSentlist;
}
return insuranceListViewModel;
return insuranceListViewModel;
}
#region client
@@ -1113,11 +1142,46 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
default: return query.OrderByDescending(x => x.Id).Skip(searchModel.PageIndex).ToList();
}
}
public async Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id)
{
var res = await _context.InsuranceListSet.Select(x => new InsuranceListConfirmOperation()
{
InsuranceListId = x.id,
Approval = new CreateInsuranceListApproval()
{
ApprovalStatus = x.EmployerApproval.Status,
Description = x.EmployerApproval.Description,
},
Debt = new CreateInsuranceListDebt()
{
Amount = x.Debt.Amount.ToMoney(),
DebtDate = x.Debt.DebtDate.ToFarsi(),
DebtFileMediaId = x.Debt.MediaId,
Type = x.Debt.Type
},
Inspection = new CreateInsuranceListInspection()
{
Type = x.Inspection.Type,
InspectionFileMediaId = x.Inspection.MediaId,
LastInspectionDate = x.Inspection.LastInspectionDateTime.ToFarsi()
},
ConfirmSentList = x.ConfirmSentlist,
}).FirstOrDefaultAsync(x => x.InsuranceListId == id);
res.Inspection.FilePath = GetInsuranceListFilePath(res.Inspection.InspectionFileMediaId);
res.Debt.FilePath = GetInsuranceListFilePath(res.Debt.DebtFileMediaId);
return res;
}
public List<InsuranceListViewModel> SearchForClientOld(InsuranceListSearchModel searchModel)
{
List<InsuranceListViewModel> list = new List<InsuranceListViewModel>();
var query = _context.InsuranceListSet.Where(x=>x.WorkshopId== searchModel.WorkshopId).ToList();
var query = _context.InsuranceListSet.Where(x => x.WorkshopId == searchModel.WorkshopId).ToList();
foreach (var item in query)
{
var insuranceWorkshopInformation = _context.InsuranceWorkshopInformationSet.FirstOrDefault(u => u.WorkshopId == item.WorkshopId);
@@ -1194,16 +1258,16 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
#endregion
public (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay,DateTime listStartDate, DateTime listEndDate, DateTime startWorkDate, DateTime leftDate, bool hasLeft)
public (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay, DateTime listStartDate, DateTime listEndDate, DateTime startWorkDate, DateTime leftDate, bool hasLeft)
{
var lefts = _context.LeftWorkInsuranceList
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x=> new
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new
{
startWork = x.StartWorkDate,
leftWork = x.LeftWorkDate == null ? listStartDate : x.LeftWorkDate.Value,
}).OrderBy(x=>x.startWork).ToList();
startWork = x.StartWorkDate,
leftWork = x.LeftWorkDate == null ? listStartDate : x.LeftWorkDate.Value,
}).OrderBy(x => x.startWork).ToList();
int countDay = 0;
foreach (var left in lefts)
{
@@ -1212,12 +1276,12 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//شمارش فقط تا روز قبل از شروع لیست انجام شود
if (left.leftWork >= listStartDate)
{
var endBeforStartList = new DateTime(listStartDate.Year, listStartDate.Month, listStartDate.Day);
end = endBeforStartList.AddDays(-1).ToPersianDateTime();
}
var count = (int)(end - start).TotalDays +1;
var endBeforStartList = new DateTime(listStartDate.Year, listStartDate.Month, listStartDate.Day);
end = endBeforStartList.AddDays(-1).ToPersianDateTime();
}
var count = (int)(end - start).TotalDays + 1;
countDay += count;
}
@@ -1226,12 +1290,12 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//تعداد سال های سابقه بیمه
int yearsCount = countDay / 365;
//بدست آوردن مزد سنوات بر اساس سابقه به سال
var baseYear = _insuranceYearlySalaryRepository.GetBaseYearByDate(listStartDate, yearsCount);
if(baseYear == 0)
if (baseYear == 0)
return (0, 0);
//اگر ترک کار کرده بود
//یا
@@ -1250,7 +1314,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
//}
return (yearsCount, baseYear);
}
@@ -1278,109 +1342,109 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
public List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceDataForEdit(long insuranceListId, DateTime startDate, DateTime endDate)
{
var res = _context.EmployeeInsurancListDataSet
.Where(x => x.InsuranceListId == insuranceListId)
.Join(_context.LeftWorkInsuranceList
.Where(x =>
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
((DateTime)x.LeftWorkDate >= startDate &&
(DateTime)x.LeftWorkDate <= endDate)) ||
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
(DateTime)x.LeftWorkDate >= endDate) ||
(x.LeftWorkDate == null || x.LeftWorkDate == DateTime.MinValue))
.Where(x => x.StartWorkDate <= endDate)
.Include(x => x.Employee),
employeeData => employeeData.EmployeeId,
leftwork => leftwork.EmployeeId,
(employeeData, leftwork) => new { employeeData, leftwork })
.Join(_context.Jobs,
result => result.leftwork.JobId,
job => job.id,
(result, job) => new { result, job })
.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(),
allResult => allResult.result.employeeData.EmployeeId,
employeeInfo => employeeInfo.EmployeeId,
(allResult, employeeInfo) => new
{
allResult.result,
allResult.job,
employeeInfo
})
.SelectMany(x => x.employeeInfo.DefaultIfEmpty(), (x, employeeInfo) => new { x, employeeInfo })
.Select(result => new EmployeeDetailsForInsuranceListViewModel
{
StartWorkDateNew = result.x.result.leftwork.StartWorkDate,
LeftWorkDateNew = result.x.result.leftwork.LeftWorkDate,
JobIdNew = result.x.result.leftwork.JobId,
StartWorkDateGr = result.x.result.leftwork.StartWorkDate,
LeftWorkDateGr = result.x.result.leftwork.LeftWorkDate,
IncludeStatus = result.x.result.employeeData.IncludeStatus,
JobId = result.x.result.employeeData.JobId,
JobName = result.x.job != null ? result.x.job.JobName : string.Empty,
JobCode = result.x.job != null ? result.x.job.JobCode : string.Empty,
InsuranceEmployeeInformationId = result.employeeInfo != null ? result.employeeInfo.id : 0,
EmployeeId = result.x.result.employeeData.EmployeeId,
//اطلاعات هویتی
FName = result.employeeInfo != null ? result.employeeInfo.FName : result.x.result.leftwork.Employee.FName,
LName = result.employeeInfo != null ? result.employeeInfo.LName : result.x.result.leftwork.Employee.LName,
FatherName = result.employeeInfo != null ? result.employeeInfo.FatherName : result.x.result.leftwork.Employee.FatherName,
DateOfBirthGr = result.employeeInfo != null ? result.employeeInfo.DateOfBirth : result.x.result.leftwork.Employee.DateOfBirth,
DateOfIssueGr = result.employeeInfo != null ? result.employeeInfo.DateOfIssue : result.x.result.leftwork.Employee.DateOfIssue,
PlaceOfIssue = result.employeeInfo != null ? result.employeeInfo.PlaceOfIssue : result.x.result.leftwork.Employee.PlaceOfIssue,
IdNumber = result.employeeInfo != null ? result.employeeInfo.IdNumber : result.x.result.leftwork.Employee.IdNumber,
Gender = result.employeeInfo != null ? result.employeeInfo.Gender : result.x.result.leftwork.Employee.Gender,
NationalCode = result.x.result.leftwork.Employee.NationalCode,
Nationality = result.x.result.leftwork.Employee.Nationality,
InsuranceCode = result.x.result.leftwork.Employee.InsuranceCode,
MaritalStatus = result.x.result.leftwork.Employee.MaritalStatus,
IsMaritalStatusSet = !string.IsNullOrWhiteSpace(result.x.result.leftwork.Employee.MaritalStatus),
//اطاعات محاسباتی
EmployeeInsurancListDataId = result.x.result.employeeData.id,
DailyWage = result.x.result.employeeData.DailyWage,
// LeftWorkDateGr = x.LeftWorkDate,
// StartWorkDateGr = x.StartWorkDate,
MonthlyBenefitsIncluded = result.x.result.employeeData.MonthlyBenefitsIncluded,
// JobId = x.JobId,
WorkingDays = result.x.result.employeeData.WorkingDays,
//پایه سنوات
BaseYears = result.x.result.employeeData.BaseYears,
//مجموع مزد روزانه و پایه سنوات
DailyWagePlusBaseYears = result.x.result.employeeData.DailyWagePlusBaseYears,
//حق تاهل
MarriedAllowance = result.x.result.employeeData.MarriedAllowance,
//دستمزد ماهانه
MonthlySalary = result.x.result.employeeData.MonthlySalary,
var res = _context.EmployeeInsurancListDataSet
.Where(x => x.InsuranceListId == insuranceListId)
.Join(_context.LeftWorkInsuranceList
.Where(x =>
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
((DateTime)x.LeftWorkDate >= startDate &&
(DateTime)x.LeftWorkDate <= endDate)) ||
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
(DateTime)x.LeftWorkDate >= endDate) ||
(x.LeftWorkDate == null || x.LeftWorkDate == DateTime.MinValue))
.Where(x => x.StartWorkDate <= endDate)
.Include(x => x.Employee),
employeeData => employeeData.EmployeeId,
leftwork => leftwork.EmployeeId,
(employeeData, leftwork) => new { employeeData, leftwork })
.Join(_context.Jobs,
result => result.leftwork.JobId,
job => job.id,
(result, job) => new { result, job })
.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(),
allResult => allResult.result.employeeData.EmployeeId,
employeeInfo => employeeInfo.EmployeeId,
(allResult, employeeInfo) => new
{
allResult.result,
allResult.job,
employeeInfo
})
.SelectMany(x => x.employeeInfo.DefaultIfEmpty(), (x, employeeInfo) => new { x, employeeInfo })
.Select(result => new EmployeeDetailsForInsuranceListViewModel
{
StartWorkDateNew = result.x.result.leftwork.StartWorkDate,
LeftWorkDateNew = result.x.result.leftwork.LeftWorkDate,
JobIdNew = result.x.result.leftwork.JobId,
//مزایای ماهانه
MonthlyBenefits = result.x.result.employeeData.MonthlyBenefits,
StartWorkDateGr = result.x.result.leftwork.StartWorkDate,
LeftWorkDateGr = result.x.result.leftwork.LeftWorkDate,
IncludeStatus = result.x.result.employeeData.IncludeStatus,
JobId = result.x.result.employeeData.JobId,
JobName = result.x.job != null ? result.x.job.JobName : string.Empty,
JobCode = result.x.job != null ? result.x.job.JobCode : string.Empty,
InsuranceEmployeeInformationId = result.employeeInfo != null ? result.employeeInfo.id : 0,
EmployeeId = result.x.result.employeeData.EmployeeId,
//مزایای مشمول
BenefitsIncludedContinuous = result.x.result.employeeData.MonthlyBenefitsIncluded,
//اطلاعات هویتی
FName = result.employeeInfo != null ? result.employeeInfo.FName : result.x.result.leftwork.Employee.FName,
LName = result.employeeInfo != null ? result.employeeInfo.LName : result.x.result.leftwork.Employee.LName,
FatherName = result.employeeInfo != null ? result.employeeInfo.FatherName : result.x.result.leftwork.Employee.FatherName,
DateOfBirthGr = result.employeeInfo != null ? result.employeeInfo.DateOfBirth : result.x.result.leftwork.Employee.DateOfBirth,
DateOfIssueGr = result.employeeInfo != null ? result.employeeInfo.DateOfIssue : result.x.result.leftwork.Employee.DateOfIssue,
PlaceOfIssue = result.employeeInfo != null ? result.employeeInfo.PlaceOfIssue : result.x.result.leftwork.Employee.PlaceOfIssue,
IdNumber = result.employeeInfo != null ? result.employeeInfo.IdNumber : result.x.result.leftwork.Employee.IdNumber,
Gender = result.employeeInfo != null ? result.employeeInfo.Gender : result.x.result.leftwork.Employee.Gender,
NationalCode = result.x.result.leftwork.Employee.NationalCode,
Nationality = result.x.result.leftwork.Employee.Nationality,
InsuranceCode = result.x.result.leftwork.Employee.InsuranceCode,
MaritalStatus = result.x.result.leftwork.Employee.MaritalStatus,
IsMaritalStatusSet = !string.IsNullOrWhiteSpace(result.x.result.leftwork.Employee.MaritalStatus),
//مزایای غیر مشمول
BenefitsIncludedNonContinuous = result.x.result.employeeData.BenefitsIncludedNonContinuous,
//اطاعات محاسباتی
EmployeeInsurancListDataId = result.x.result.employeeData.id,
DailyWage = result.x.result.employeeData.DailyWage,
// LeftWorkDateGr = x.LeftWorkDate,
// StartWorkDateGr = x.StartWorkDate,
MonthlyBenefitsIncluded = result.x.result.employeeData.MonthlyBenefitsIncluded,
// JobId = x.JobId,
WorkingDays = result.x.result.employeeData.WorkingDays,
//پایه سنوات
BaseYears = result.x.result.employeeData.BaseYears,
// جمع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول
IncludedAndNotIncluded = result.x.result.employeeData.BenefitsIncludedContinuous,
//مجموع مزد روزانه و پایه سنوات
DailyWagePlusBaseYears = result.x.result.employeeData.DailyWagePlusBaseYears,
//حق بیمه سهم بیمه شده
InsuranceShare = result.x.result.employeeData.InsuranceShare,
//حق تاهل
MarriedAllowance = result.x.result.employeeData.MarriedAllowance,
//اضافه کار فیش حقوقی
OverTimePay = result.x.result.employeeData.OverTimePay,
//دستمزد ماهانه
MonthlySalary = result.x.result.employeeData.MonthlySalary,
//حق اولا فیش حقوقی
FamilyAllowance = result.x.result.employeeData.FamilyAllowance,
});
//مزایای ماهانه
MonthlyBenefits = result.x.result.employeeData.MonthlyBenefits,
//مزایای مشمول
BenefitsIncludedContinuous = result.x.result.employeeData.MonthlyBenefitsIncluded,
//مزایای غیر مشمول
BenefitsIncludedNonContinuous = result.x.result.employeeData.BenefitsIncludedNonContinuous,
// جمع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول
IncludedAndNotIncluded = result.x.result.employeeData.BenefitsIncludedContinuous,
//حق بیمه سهم بیمه شده
InsuranceShare = result.x.result.employeeData.InsuranceShare,
//اضافه کار فیش حقوقی
OverTimePay = result.x.result.employeeData.OverTimePay,
//حق اولا فیش حقوقی
FamilyAllowance = result.x.result.employeeData.FamilyAllowance,
});
//.Select(x => new EmployeeDetailsForInsuranceListViewModel
@@ -1427,4 +1491,45 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
return res.ToList();
}
public async Task<InsuranceListTabsCountViewModel> GetTabCounts(long accountId, int month, int year)
{
var workshopIds = _context.WorkshopAccounts
.Where(a => a.AccountId == accountId)
.Select(a => a.WorkshopId);
var res = await _context.InsuranceListSet
.Where(x =>
x.Year == year.ToString("0000") &&
x.Month == month.ToString("00") &&
workshopIds.Contains(x.WorkshopId)
)
.GroupBy(x => 1)
.Select(g => new InsuranceListTabsCountViewModel
{
NotStarted = g.Count(x =>
!x.Debt.IsDone && !x.EmployerApproval.IsDone && !x.Inspection.IsDone && !x.ConfirmSentlist),
InProgress = g.Count(x =>
(x.Debt.IsDone || x.EmployerApproval.IsDone || x.Inspection.IsDone)&& !(x.Debt.IsDone && x.EmployerApproval.IsDone && x.Inspection.IsDone) && !x.ConfirmSentlist),
ReadyToSendList = g.Count(x =>
x.Debt.IsDone && x.EmployerApproval.IsDone && x.Inspection.IsDone && !x.ConfirmSentlist),
Done = g.Count(x => x.ConfirmSentlist)
})
.FirstOrDefaultAsync() ?? new InsuranceListTabsCountViewModel();
return res;
}
/// <summary>
///
/// </summary>
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="insuranceListId"></param>
/// <param name="type">debt / inspection</param>
/// <returns></returns>
private string GetInsuranceListFilePath(long mediaId)
{
return _accountContext.Medias.FirstOrDefault(x => x.id == mediaId)?.Path ?? "";
}
}

View File

@@ -796,5 +796,11 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
return insuranceLeftWorkWithContractExitOnly.ToList();
}
public LeftWorkInsurance GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId)
{
return _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
.OrderByDescending(x => x.StartWorkDate).FirstOrDefault();
}
#endregion
}

View File

@@ -654,7 +654,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
var vipGroup = _context.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
var clientTemps = _context.EmployeeClientTemps.Where(x => x.WorkshopId == searchModel.WorkshopId)
.Select(x => x.EmployeeId);
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
{
Id = x.id,
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
@@ -672,7 +675,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
JobName = _context.Jobs.FirstOrDefault(j => j.id == x.JobId).JobName
}).Where(x=> !vipGroup.Contains(x.EmployeeId));
}).Where(x=> !vipGroup.Contains(x.EmployeeId) && !clientTemps.Contains(x.EmployeeId));
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId == 0)

View File

@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Exceptions;
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.Account;
using AccountMangement.Infrastructure.EFCore;
@@ -478,6 +481,248 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
#endregion
#region Api
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel)
{
var personalContractingPartiesQuery = _context.PersonalContractingParties
.Include(x => x.Representative)
.Include(x => x.Employers).AsQueryable();
if (!string.IsNullOrWhiteSpace(searchModel.NationalIdOrNationalCode))
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.Nationalcode.Contains(searchModel.NationalIdOrNationalCode) ||
x.NationalId.Contains(searchModel.NationalIdOrNationalCode));
if (searchModel.ContractingPartyType != LegalType.None)
{
string type = searchModel.ContractingPartyType switch
{
LegalType.Legal => "حقوقی",
LegalType.Real => "حقیقی",
_ => ""
};
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.IsLegal == type);
}
if (searchModel.ContractingPartyStatus != ActivationStatus.None)
{
string status = searchModel.ContractingPartyStatus switch
{
ActivationStatus.Active => "true",
ActivationStatus.DeActive => "false",
_ => ""
};
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.IsActiveString == status);
}
if (!string.IsNullOrWhiteSpace(searchModel.RepresentativeName))
{
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.Representative.FullName.Contains(searchModel.RepresentativeName));
}
if (!string.IsNullOrWhiteSpace(searchModel.FullNameOrCompanyName))
{
personalContractingPartiesQuery = personalContractingPartiesQuery.Where(x =>
(x.FName + " " + x.LName).Contains(searchModel.FullNameOrCompanyName));
}
var joinedQuery = personalContractingPartiesQuery
.GroupJoin(_context.InstitutionContractSet.Where(x => personalContractingPartiesQuery.Any(p => p.id == x.ContractingPartyId)),
contractingParty => contractingParty.id,
institution => institution.ContractingPartyId,
(contractingParty, institution) => new
{
contractingParty,
institution
});
var result = await joinedQuery.Skip(searchModel.PageIndex)
.Take(30).Select(x => new ContractingPartyGetListViewModel()
{
ArchiveCode = x.contractingParty.ArchiveCode,
BlockTimes = x.contractingParty.BlockTimes,
ContractingPartyName = x.contractingParty.IsLegal == "حقیقی" ?
x.contractingParty.SureName == null ? $"{x.contractingParty.FName} {x.contractingParty.LName}"
: $"{x.contractingParty.FName} {x.contractingParty.LName} {x.contractingParty.SureName}"
: x.contractingParty.SureName == null ? $"{x.contractingParty.LName}"
: $"{x.contractingParty.LName} {x.contractingParty.SureName}",
ContractingPartyType = x.contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
Employers = x.contractingParty.Employers.Take(11).Select(e => new ContractingPartyGetListEmployerViewModel(e.id, e.FullName)).ToList(),
Id = x.contractingParty.id,
IsBlock = x.contractingParty.IsBlock == "true",
HasInstitutionContract = x.institution.Any(i => i.IsActiveString == "true"),
NationalIdOrNationalCode = x.contractingParty.IsLegal == "حقیقی" ? x.contractingParty.Nationalcode : x.contractingParty.NationalId,
Status = x.contractingParty.IsActiveString == "true" ? ActivationStatus.Active : ActivationStatus.DeActive
}).ToListAsync();
return result;
}
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
{
return await _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
{
Id = x.id,
Text = x.IsLegal == "حقیقی" ? x.SureName == null
? $"{x.FName} {x.LName}"
: $"{x.FName} {x.LName} {x.SureName}"
: x.SureName == null ? $"{x.LName}"
: $"{x.LName} {x.SureName}",
}).ToListAsync();
}
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
{
return await _context.PersonalContractingParties.Select(x => new GetContractingPartyNationalCodeOrNationalIdViewModel
{
NationalCodeOrNationalId = x.IsLegal == "true" ? x.NationalId : x.Nationalcode
}).ToListAsync();
}
public async Task<OperationResult<string>> DeactivateWithSubordinates(long id)
{
var op = new OperationResult<string>();
;
using (var transaction = await _context.Database.BeginTransactionAsync())
{
try
{
var contractingParty = await _context.PersonalContractingParties
.Include(x => x.Employers)
.ThenInclude(x => x.Contracts)
.Include(x => x.Employers)
.ThenInclude(x => x.WorkshopEmployers)
.ThenInclude(x => x.Workshop)
.ThenInclude(x => x.Checkouts).FirstOrDefaultAsync(x => x.id == id);
if (contractingParty == null)
{
return op.Failed("چنین آیتمی وجود ندارد");
}
var employers = contractingParty.Employers;
var workshops = employers.SelectMany(x => x.WorkshopEmployers).Select(x => x.Workshop).ToList();
var contracts = employers.SelectMany(x => x.Contracts).ToList();
var checkouts = workshops.SelectMany(x => x.Checkouts).ToList();
contractingParty.DeActive();
foreach (var employer in employers)
{
employer.DeActive();
}
foreach (var workshop in workshops)
{
workshop.DeActive(workshop.ArchiveCode);
}
foreach (var contract in contracts)
{
contract.DeActive();
}
foreach (var checkout in checkouts)
{
checkout.DeActive();
}
await _context.SaveChangesAsync();
await transaction.CommitAsync();
return op.Succcedded("DeActivate");
}
catch (Exception)
{
await transaction.RollbackAsync();
return op.Failed("غیرفعال کردن طرف حساب با خطا مواجه شد");
}
}
}
public async Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id)
{
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقیقی").Select(x =>
new GetRealContractingPartyDetailsViewModel()
{
Id = x.id,
IdNumber = x.IdNumber,
PhoneNumber = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
FullName = x.SureName == null
? $"{x.FName} {x.LName}"
: $"{x.FName} {x.LName} {x.SureName}",
NationalCode = x.Nationalcode,
RepresentativeName = x.RepresentativeFullName,
ArchiveCode = x.ArchiveCode,
City = x.City,
FName = x.FName,
LName = x.LName,
SureName = x.SureName,
RepresentativeId = x.RepresentativeId,
State = x.State,
Zone = x.Zone
}).FirstOrDefaultAsync(x => x.Id == id);
if (res == null)
{
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
}
return res;
}
public async Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id)
{
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقوقی").Select(x =>
new GetLegalContractingPartyDetailsViewModel()
{
Id = x.id,
PhoneNumber = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
CompanyFullName = x.SureName == null
? $"{x.LName}"
: $"{x.LName} {x.SureName}",
NationalId = x.NationalId,
RegisterId = x.RegisterId,
RepresentativeName = x.RepresentativeFullName,
RepresentativeId = x.RepresentativeId,
State = x.State,
SureName = x.SureName,
Zone = x.Zone,
ArchiveCode = x.ArchiveCode,
City = x.City,
CompanyName = x.LName
}).FirstOrDefaultAsync(x => x.Id == id);
if (res == null)
{
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
}
return res;
}
#endregion
}
#endregion

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.InstitutionPlanAgg;
@@ -170,7 +169,6 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
}
public InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command)
{
var planPercentage = _context.PlanPercentages.FirstOrDefault();
@@ -184,7 +182,10 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه")
.Select(x => x.ItemValue).FirstOrDefault();
if (command.ContractAndCheckout)
command.ContractAndCheckoutInPerson = true;
if(command.Insurance)
command.InsuranceInPerson = true;
if (command.CountPerson > 0)
{
@@ -193,28 +194,28 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
.Select(plan => new InstitutionPlanViewModel
{
CountPerson = plan.CountPerson,
ContractAndCheckoutDouble = command.ContractAndCheckout ?
((dailyWage * planPercentage.ContractAndCheckoutPercent / 100) * plan.CountPerson * plan.IncreasePercentage) : 0,
InsuranceDouble = command.Insurance ? (((dailyWage * planPercentage.InsurancePercent) / 100) * plan.CountPerson *
plan.IncreasePercentage) : 0,
RollCallDouble = command.RollCall ? (((dailyWage * planPercentage.RollCallPercent) / 100) * plan.CountPerson *
plan.IncreasePercentage) : 0,
CustomizeCheckoutDouble = (((dailyWage * planPercentage.CustomizeCheckoutPercent) / 100) * plan.CountPerson *
plan.IncreasePercentage),
ContractAndCheckoutInPersonDouble = command.ContractAndCheckoutInPerson ? (((dailyWage * planPercentage.ContractAndCheckoutInPersonPercent) / 100) * plan.CountPerson *
CustomizeCheckoutDouble =command.CustomizeCheckout ? (((dailyWage * planPercentage.CustomizeCheckoutPercent) / 100) * plan.CountPerson *
plan.IncreasePercentage) : 0,
ContractAndCheckoutInPersonDouble = command.ContractAndCheckoutInPerson ? (((dailyWage * planPercentage.ContractAndCheckoutInPersonPercent) / 100) * plan.CountPerson *
plan.IncreasePercentage) : 0,
InsuranceInPersonDouble = command.InsuranceInPerson ? (((dailyWage * planPercentage.InsuranceInPersonPercent) / 100) * plan.CountPerson *
plan.IncreasePercentage) : 0,
}).FirstOrDefault();
if(planByCountPerson == null)
if (planByCountPerson == null)
return new InstitutionPlanViewModel();
//مبلغ کل خدمات حضوری
var inPersonSumAmount = planByCountPerson.ContractAndCheckoutDouble + planByCountPerson.InsuranceDouble +
@@ -236,7 +237,7 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
{
CountPerson = planByCountPerson.CountPerson,
ContractAndCheckout = planByCountPerson.ContractAndCheckoutDouble > 0 ? planByCountPerson.ContractAndCheckoutDouble.ToMoney() : "0",
ContractAndCheckout = planByCountPerson.ContractAndCheckoutDouble > 0 ? planByCountPerson.ContractAndCheckoutDouble.ToMoney() : "0",
Insurance = planByCountPerson.InsuranceDouble > 0 ? planByCountPerson.InsuranceDouble.ToMoney() : "0",
@@ -259,7 +260,7 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
};
}
return new InstitutionPlanViewModel();
}

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