diff --git a/0_Framework/Application/UID/UidService.cs b/0_Framework/Application/UID/UidService.cs index 3d472dcb..ccf3c0ef 100644 --- a/0_Framework/Application/UID/UidService.cs +++ b/0_Framework/Application/UID/UidService.cs @@ -10,67 +10,70 @@ namespace _0_Framework.Application.UID; public class UidService : IUidService { - private readonly HttpClient _httpClient; - private const string BaseUrl= "https://json-api.uid.ir/api/inquiry/"; + private readonly HttpClient _httpClient; + private const string BaseUrl = "https://json-api.uid.ir/api/inquiry/"; - public UidService() - { - _httpClient = new HttpClient() - { - BaseAddress = new Uri(BaseUrl) - }; - } + public UidService() + { + _httpClient = new HttpClient() + { + BaseAddress = new Uri(BaseUrl) + }; + } - public async Task GetPersonalInfo(string nationalCode, string birthDate) - { - var request = new PersonalInfoRequest - { - BirthDate = birthDate , - NationalId = nationalCode, - RequestContext = new UidRequestContext() - }; - var json = JsonConvert.SerializeObject(request); - var contentType = new StringContent(json, Encoding.UTF8, "application/json"); + public async Task GetPersonalInfo(string nationalCode, string birthDate) + { + var request = new PersonalInfoRequest + { + BirthDate = birthDate, + NationalId = nationalCode, + RequestContext = new UidRequestContext() + }; + var json = JsonConvert.SerializeObject(request); + var contentType = new StringContent(json, Encoding.UTF8, "application/json"); - var requestResult = await _httpClient.PostAsync("person/v2", contentType); - try - { - if (!requestResult.IsSuccessStatusCode) - return null; - var responseResult = await requestResult.Content.ReadFromJsonAsync(); - if (responseResult.BasicInformation != null) - { - responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian(); - responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian(); - responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian(); - } + try + { + var requestResult = await _httpClient.PostAsync("person/v2", contentType); + if (!requestResult.IsSuccessStatusCode) + return null; + var responseResult = await requestResult.Content.ReadFromJsonAsync(); + if (responseResult.BasicInformation != null) + { + responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian(); + responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian(); + responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian(); + } - return responseResult; - } - catch - { + return responseResult; + } + catch + { - return null; - } - } + return new PersonalInfoResponse(new UidBasicInformation(), + new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(), + new ResponseContext(new UidStatus(14, ""))); + } + + } - public async Task IsMachPhoneWithNationalCode(string nationalCode, string phoneNumber) - { - var request = new PersonalInfoRequest - { - MobileNumber = phoneNumber, - NationalId = nationalCode, - RequestContext = new UidRequestContext() - }; - var json = JsonConvert.SerializeObject(request); - var contentType = new StringContent(json, Encoding.UTF8, "application/json"); + public async Task IsMachPhoneWithNationalCode(string nationalCode, string phoneNumber) + { + var request = new PersonalInfoRequest + { + MobileNumber = phoneNumber, + NationalId = nationalCode, + RequestContext = new UidRequestContext() + }; + var json = JsonConvert.SerializeObject(request); + var contentType = new StringContent(json, Encoding.UTF8, "application/json"); - var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType); - if (!requestResult.IsSuccessStatusCode) - return null; + var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType); + if (!requestResult.IsSuccessStatusCode) + return null; - var responseResult = await requestResult.Content.ReadFromJsonAsync(); - return responseResult; - } + var responseResult = await requestResult.Content.ReadFromJsonAsync(); + return responseResult; + } } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Employee/EmployeeDataFromApiViewModel.cs b/CompanyManagment.App.Contracts/Employee/EmployeeDataFromApiViewModel.cs index c28dc277..c6fca7ad 100644 --- a/CompanyManagment.App.Contracts/Employee/EmployeeDataFromApiViewModel.cs +++ b/CompanyManagment.App.Contracts/Employee/EmployeeDataFromApiViewModel.cs @@ -26,4 +26,5 @@ public class EmployeeDataFromApiViewModel /// public string IdNumberSeri { get; set; } + public bool AuthorizedCanceled { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index 7201bbac..466acf36 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -197,6 +197,7 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli return opration.Failed("کد ملی وارد شده تکراری است"); } } + @@ -1539,7 +1540,11 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli if (employee.IsAuthorized == false) { var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate); + if (apiResult.ResponseContext.Status.Code == 14) + { + return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد"); + } if (apiResult.ResponseContext.Status.Code != 0) { return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); @@ -1595,7 +1600,16 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli return op.Succcedded(data); } var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate); + if (apiResult.ResponseContext.Status.Code == 14) + { + return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true }); + } + + if (apiResult.ResponseContext.Status.Code == 3) + { + return op.Failed("کد ملی نامعتبر است"); + } if (apiResult.ResponseContext.Status.Code != 0) { return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml index be5f8e23..32b0cd0e 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml @@ -548,37 +548,105 @@ var codeMelli = $('#iniCodeMelli').val(); try { - const response = await $.ajax({ + const response = $.ajax({ url: loadUidInfo, method: 'POST', data: { nationalCode: codeMelli, birthDate: birthday }, - headers: { "RequestVerificationToken": antiForgeryToken } + headers: { "RequestVerificationToken": antiForgeryToken }, + success: function(response) { + debugger; + if (response.success) { + $('#IsAuthorized').val(true); + $('#name').val(response.data.fName); + $('#family').val(response.data.lName); + $('#FatherName').val(response.data.fatherName); + $('#DateOfBirth').val(response.data.birthDate); + $('#code-melli').val(response.data.nationalCode); + $('#IdNumber').val(response.data.idNumber); + $('#IdNumberSerial').val(response.data.idNumberSerial); + $('#IdNumberSeri').val(response.data.idNumberSeri); + if (response.data.gender === 0) { + $('#GenderMale').prop('checked', true); + $('#soldier').prop('disabled', false); + } else if (response.data.gender === 1) { + $('#GenderFemale').prop('checked', true); + $('#soldier').prop('disabled', true); + } + currentStep++; + showStep(currentStep); + } + else if (response.data?.authorizedCanceled) { + + $('#name').removeClass("disable"); + $('#family').removeClass("disable"); + $('#FatherName').removeClass("disable"); + $('#DateOfBirth').removeClass("disable"); + $('#code-melli').removeClass("disable"); + $('#IdNumber').removeClass("disable"); + $('#IdNumberSerial').removeClass("disable"); + $('#IdNumberSeri').removeClass("disable"); + $('#GenderMale').removeClass("disable"); + $('#GenderFemale').removeClass("disable"); + $('#divGender .radio-box').removeClass('disable'); + currentStep++; + showStep(currentStep); + $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); + return; + } + else { + $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); + return; + } + }, + error:function(error) { + $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); + return; + } }); + // debugger; + // if (response.success) { + // $('#IsAuthorized').val(true); + // $('#name').val(response.data.fName); + // $('#family').val(response.data.lName); + // $('#FatherName').val(response.data.fatherName); + // $('#DateOfBirth').val(response.data.birthDate); + // $('#code-melli').val(response.data.nationalCode); + // $('#IdNumber').val(response.data.idNumber); + // $('#IdNumberSerial').val(response.data.idNumberSerial); + // $('#IdNumberSeri').val(response.data.idNumberSeri); + // if (response.data.gender === 0) { + // $('#GenderMale').prop('checked', true); + // $('#soldier').prop('disabled', false); + // } else if (response.data.gender === 1) { + // $('#GenderFemale').prop('checked', true); + // $('#soldier').prop('disabled', true); + // } + // } + // else if (response.data.authorizedCanceled) { - if (response.success) { - $('#IsAuthorized').val(true); - $('#name').val(response.data.fName); - $('#family').val(response.data.lName); - $('#FatherName').val(response.data.fatherName); - $('#DateOfBirth').val(response.data.birthDate); - $('#code-melli').val(response.data.nationalCode); - $('#IdNumber').val(response.data.idNumber); - $('#IdNumberSerial').val(response.data.idNumberSerial); - $('#IdNumberSeri').val(response.data.idNumberSeri); - if (response.data.gender === 0) { - $('#GenderMale').prop('checked', true); - $('#soldier').prop('disabled', false); - } else if (response.data.gender === 1) { - $('#GenderFemale').prop('checked', true); - $('#soldier').prop('disabled', true); - } - } else { - $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); - return; - } + // $('#name').removeClass("disable"); + // $('#family').removeClass("disable"); + // $('#FatherName').removeClass("disable"); + // $('#DateOfBirth').removeClass("disable"); + // $('#code-melli').removeClass("disable"); + // $('#IdNumber').removeClass("disable"); + // $('#IdNumberSerial').removeClass("disable"); + // $('#IdNumberSeri').removeClass("disable"); + // $('#GenderMale').removeClass("disable"); + // $('#GenderFemale').removeClass("disable"); + // $('#divGender .radio-box').removeClass('disable'); + // currentStep++; + // showStep(currentStep); + // $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); + // return; + // } + // else { + // $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message); + // return; + // } - currentStep++; - showStep(currentStep); + // currentStep++; + // showStep(currentStep); } catch (error) { $.Notification.autoHideNotify('error', 'top right', 'خطا', "ارسال اطلاعات با مشکل مواجه شد."); return; diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml new file mode 100644 index 00000000..4df980de --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml @@ -0,0 +1,1153 @@ +@using _0_Framework.Application +@model CompanyManagment.App.Contracts.Employee.CreateEmployee + +@{ + var adminVersion = _0_Framework.Application.Version.AdminVersion; +} + + + +
+ + مشخصات پرسنل جدید +
+
+
+
مشخصات سامانه ای
+
مشخصات تکمیلی
+
مشخصات اجباری
+
احراز هویت
+
+
+
+
+
+ + + +
+ + + +

فقط عدد وارد شود.

+
+
+
+
+ + + +

فقط عدد وارد شود.

+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ + + +

فقط حروف فارسی وارد شود.

+
+
+ + + +

فقط حروف فارسی وارد شود.

+
+
+ + + +

فقط حروف فارسی وارد شود.

+
+
+ + + +

فقط عدد وارد شود.

+
+
+
+
+ + + +

فقط عدد وارد شود.

+
+
+ + + +

فقط عدد وارد شود.

+
+
+ + +
+
+ + + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + +
تاریخ تولدنام فرزند #
+
+ +
+ +
+
+ +
+
1
+
+ افزودن فرزند +
+ +
+
+
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + +

فقط عدد وارد شود.

+
+
+ + + +

فقط حروف فارسی وارد شود.

+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ اداره کار +
+
+ + +
+
+
+
+ + +
+
+
+
+ تامین اجتماعی +
+
+ + +
+
+
+
+ + +
+
+
+
+ قوه قضائیه +
+
+ + +
+
+
+
+ + +
+
+
+
+ امور مالیاتی +
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+ + diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml index 51278d85..dcfb2559 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml @@ -320,7 +320,7 @@

- ایجاد پرسنل جدید + ایجاد پرسنل جدید

ویرایش گروهی کد پرسنلی diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml.cs index fd0866e6..53bd9e0b 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/Index.cshtml.cs @@ -161,11 +161,16 @@ public class IndexModel : PageModel #endregion + #region Create Employee File پرونده public IActionResult OnGetCreate() { return Partial("./Create"); } - + ///

+ /// ایجاد پرسنل پرونده + /// + /// + /// public IActionResult OnPostCreate(CreateEmployee command) { var children = command.CreateEmployeChildrenList.Count(x => x.DateOfBirth != null); @@ -188,8 +193,56 @@ public class IndexModel : PageModel } return new JsonResult(result); + } + #endregion + + + #region Create admin Employee + public IActionResult OnGetCreateEmployee() + { + return Partial("./CreateEmployee"); } + /// + /// ایجاد پرسنل در ادمین + /// + /// + /// + public IActionResult OnPostCreateEmployee(CreateEmployee command) + { + + var children = command.CreateEmployeChildrenList.Count(x => x.DateOfBirth != null); + command.NumberOfChildren = children.ToString(); + var result = new OperationResult(); + + if (string.IsNullOrWhiteSpace(command.NationalCode)) + return new JsonResult(result.Failed("لطفا کد ملی را وارد نمایید")); + + + if (string.IsNullOrWhiteSpace(command.MaritalStatus)) + return new JsonResult(result.Failed("لطفا وضعیت تاهل را مشخص نمایید")); + + result = _employeeApplication.Create(command); + Thread.Sleep(1000); + + if (result.IsSuccedded) + for (var i = 0; i <= children - 1; i++) + if (command.CreateEmployeChildrenList[i].DateOfBirth != null) + { + var child = new CreateEmployeChildren + { + ParentNationalCode = command.NationalCode, + DateOfBirth = command.CreateEmployeChildrenList[i].DateOfBirth, + FName = command.CreateEmployeChildrenList[i].FName, + EmployeeId = result.SendId + }; + _employeeChildrenApplication.Create(child); + } + + return new JsonResult(result); + } + #endregion + public IActionResult OnGetEdit(long id) {