Merge branch 'Feature/InstitutionContract/add-registration-style' into Main
This commit is contained in:
@@ -1302,109 +1302,6 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return await _institutionContractRepository.ExtensionComplete(request);
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionInquiryResponse> ExtensionInquiry(InstitutionContractExtensionInquiryRequest command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
#region Validations
|
||||
if (string.IsNullOrWhiteSpace(command.NationalCode) || string.IsNullOrWhiteSpace(command.BirthDate) ||
|
||||
string.IsNullOrWhiteSpace(command.Mobile))
|
||||
throw new BadRequestException("هیچ یک از فیلد ها نمیتواند خالی باشد");
|
||||
|
||||
if (command.NationalCode.NationalCodeValid() != "valid")
|
||||
throw new BadRequestException("کد ملی نا معتبر است");
|
||||
|
||||
if (!command.BirthDate.TryToGeorgianDateTime(out var dateOfBirthGr))
|
||||
throw new BadRequestException("تاریخ تولد نا معتبر است");
|
||||
|
||||
if (!command.Mobile.IsMobileValid())
|
||||
throw new BadRequestException("شماره همراه نا معتبر است");
|
||||
#endregion
|
||||
|
||||
var contractingParty = _contractingPartyRepository.Get(command.ContractingPartyId);
|
||||
|
||||
if (contractingParty == null)
|
||||
throw new BadRequestException("طرف حسابی یافت نشد");
|
||||
|
||||
// بررسی اینکه آیا طرف حساب قبلا احراز هویت شده یا نه
|
||||
if (contractingParty.IsAuthenticated)
|
||||
throw new BadRequestException("طرف حساب قبلا احراز هویت شده است");
|
||||
|
||||
|
||||
|
||||
// // بررسی تطابق تاریخ تولد
|
||||
// if (contractingParty.DateOfBirth != null && contractingParty.DateOfBirth != dateOfBirthGr)
|
||||
// return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
|
||||
// // بررسی تطابق شماره تماس
|
||||
// if (contractingParty.Phone != command.Mobile)
|
||||
// return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
|
||||
// چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(command.NationalCode, command.Mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
throw new BadRequestException("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
throw new BadRequestException("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
// دریافت اطلاعات احراز هویت
|
||||
var apiResponse = await _uidService.GetPersonalInfo(command.NationalCode, command.BirthDate);
|
||||
|
||||
if (apiResponse == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiResponse.ResponseContext.Status.Code == 14)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiResponse.ResponseContext.Status.Code != 0)
|
||||
throw new BadRequestException($"{apiResponse.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiResponse.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiResponse.IdentificationInformation.NationalId
|
||||
: apiResponse.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
if (contractingParty.IsLegal =="حقیقی")
|
||||
{
|
||||
// انجام احراز هویت طرف حساب
|
||||
contractingParty.Authentication(apiResponse.BasicInformation.FirstName,
|
||||
apiResponse.BasicInformation.LastName,
|
||||
apiResponse.BasicInformation.FatherName,
|
||||
idNumber,
|
||||
apiResponse.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponse.IdentificationInformation.ShenasnameSerial,
|
||||
command.BirthDate,
|
||||
apiResponse.BasicInformation.GenderEnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
contractingParty.LegalAuthentication(apiResponse.BasicInformation.FirstName,
|
||||
apiResponse.BasicInformation.LastName,
|
||||
apiResponse.BasicInformation.FatherName,
|
||||
idNumber,
|
||||
apiResponse.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponse.IdentificationInformation.ShenasnameSerial,
|
||||
command.BirthDate,
|
||||
apiResponse.BasicInformation.GenderEnum);
|
||||
}
|
||||
// ذخیره تغییرات
|
||||
await _contractingPartyRepository.SaveChangesAsync();
|
||||
|
||||
var result = new InstitutionContractExtensionInquiryResponse();
|
||||
result.Id = contractingParty.id;
|
||||
result.FName = contractingParty.FName;
|
||||
result.LName = contractingParty.LName;
|
||||
result.DateOfBirthFa = command.BirthDate;
|
||||
result.FatherName = contractingParty.FatherName;
|
||||
result.IdNumberSerial = contractingParty.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.Address = contractingParty.Address;
|
||||
result.Phone = contractingParty.Phone;
|
||||
result.City = contractingParty.City;
|
||||
result.State = contractingParty.State;
|
||||
result.RepresentativeId = contractingParty.RepresentativeId;
|
||||
result.NationalCode = contractingParty.Nationalcode;
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,
|
||||
|
||||
Reference in New Issue
Block a user