Compare commits
6 Commits
Feature/Lo
...
Feature/cl
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d3d599449 | |||
| 2d28bd1f98 | |||
| 75ae3efb65 | |||
| eb53fd67ef | |||
| 8ec717916c | |||
| 64bdbcbd2d |
@@ -251,6 +251,35 @@ public class PersonalContractingParty : EntityBase
|
||||
this.IsAuthenticated = true;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
public void UnAuthenticateRealEdit(string fName, string lName, string fatherName,string idNumber,
|
||||
string idNumberSeri, string idNumberSerial, string dateOfBirth, Gender gender,string phone)
|
||||
{
|
||||
this.FName = fName;
|
||||
this.LName = lName;
|
||||
this.FatherName = fatherName;
|
||||
this.IdNumberSeri = idNumberSeri;
|
||||
this.IdNumberSerial = idNumberSerial;
|
||||
this.DateOfBirth = !string.IsNullOrWhiteSpace(dateOfBirth) ? dateOfBirth.ToGeorgianDateTime() : null;
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
public void UnAuthenticateLegalEdit(string fName, string lName, string fatherName, string idNumber,
|
||||
string idNumberSeri,
|
||||
string idNumberSerial, string dateOfBirth, Gender gender, string phone)
|
||||
{
|
||||
CeoFName = fName;
|
||||
CeoLName = lName;
|
||||
this.FatherName = fatherName;
|
||||
this.IdNumberSeri = idNumberSeri;
|
||||
this.IdNumberSerial = idNumberSerial;
|
||||
this.DateOfBirth = !string.IsNullOrWhiteSpace(dateOfBirth) ? dateOfBirth.ToGeorgianDateTime() : null;
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
public void RegisterComplete(string fatherName, string idNumberSeri, string idNumberSerial, DateTime dateOfBirth, Gender gender)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||
@@ -11,4 +12,15 @@ public class InstitutionContractExtensionWorkshopsRequest
|
||||
public string Province { get; set; }
|
||||
public string Address { get; set; }
|
||||
public List<EditContactInfo> ContactInfos { get; set; }
|
||||
/// <summary>
|
||||
/// اطلاعات شخص حقیقی
|
||||
/// </summary>
|
||||
public CreateInstitutionContractRealPartyRequest RealParty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// اطلاعات شخص حقوقی
|
||||
/// </summary>
|
||||
public CreateInstitutionContractLegalPartyRequest LegalParty { get; set; }
|
||||
|
||||
public LegalType LegalType { get; set; }
|
||||
}
|
||||
@@ -974,6 +974,13 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
|
||||
if (!command.LegalParty.IsAuth)
|
||||
{
|
||||
var legalCommand = command.LegalParty;
|
||||
existingContractingParty.UnAuthenticateLegalEdit(legalCommand.FName,legalCommand.LName,legalCommand.FatherName,legalCommand.IdNumber,existingContractingParty.IdNumberSeri,existingContractingParty.IdNumberSerial,
|
||||
legalCommand.BirthDateFa,legalCommand.Gender,legalCommand.PhoneNumber);
|
||||
}
|
||||
}
|
||||
else if (command.ContractingPartyLegalType == LegalType.Real)
|
||||
{
|
||||
@@ -990,8 +997,15 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
if (!command.RealParty.IsAuth)
|
||||
{
|
||||
var realCommand = command.RealParty;
|
||||
existingContractingParty.UnAuthenticateRealEdit(realCommand.FName,realCommand.LName,realCommand.FatherName,realCommand.IdNumber,existingContractingParty.IdNumberSeri,existingContractingParty.IdNumberSerial,
|
||||
realCommand.BirthDateFa,realCommand.Gender,realCommand.PhoneNumber);
|
||||
}
|
||||
}
|
||||
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
PersonalContractingParty contractingParty;
|
||||
if (existingContractingParty != null)
|
||||
{
|
||||
|
||||
@@ -119,27 +119,29 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiResponsParty = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
if (apiResponsParty == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiResponsParty.ResponseContext.Status.Code ==14)
|
||||
if (apiResponsParty.ResponseContext.Status.Code is 14 or 3)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiResponsParty.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiResponsParty.ResponseContext.Status.Message}");
|
||||
|
||||
idNumberParty = apiResponsParty.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
idNumberParty = apiResponsParty.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiResponsParty.IdentificationInformation.NationalId
|
||||
: apiResponsParty.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
throw new InternalServerException("خطا در سرویس تطابق کد ملی و شماره همراه");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
contractingParty.Authentication(apiResponsParty.BasicInformation.FirstName, apiResponsParty.BasicInformation.LastName,
|
||||
apiResponsParty.BasicInformation.FatherName,idNumberParty,apiResponsParty.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponsParty.IdentificationInformation.ShenasnameSerial,dateOfBirth,apiResponsParty.BasicInformation.GenderEnum,
|
||||
@@ -147,12 +149,11 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
if (contractingParty.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری احراز هویت شده اید");
|
||||
|
||||
|
||||
result.Id = contractingParty.id;
|
||||
result.FName = contractingParty.FName;
|
||||
result.LName = contractingParty.LName;
|
||||
@@ -206,7 +207,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
if (apiRespons == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code == 14)
|
||||
if (apiRespons.ResponseContext.Status.Code is 14 or 3)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code == 2)
|
||||
|
||||
@@ -42,6 +42,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using MongoDB.Driver;
|
||||
using OfficeOpenXml.Packaging.Ionic.Zip;
|
||||
@@ -1961,13 +1962,51 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
public async Task<InstitutionContractExtensionWorkshopsResponse> GetExtensionWorkshops(
|
||||
InstitutionContractExtensionWorkshopsRequest request)
|
||||
{
|
||||
var transaction = await _context.Database.BeginTransactionAsync();
|
||||
switch (request.LegalType)
|
||||
{
|
||||
case LegalType.Legal:
|
||||
if (!request.LegalParty.IsAuth)
|
||||
{
|
||||
var legalCommand = request.LegalParty;
|
||||
var personalContractingParty = _context.PersonalContractingParties
|
||||
.FirstOrDefault(x=>x.NationalId == legalCommand.NationalId);
|
||||
if (personalContractingParty is {IsAuthenticated:false})
|
||||
{
|
||||
personalContractingParty.UnAuthenticateLegalEdit(legalCommand.FName, legalCommand.LName,
|
||||
legalCommand.FatherName, legalCommand.IdNumber, personalContractingParty.IdNumberSeri,
|
||||
personalContractingParty.IdNumberSerial, legalCommand.BirthDateFa, legalCommand.Gender,
|
||||
legalCommand.PhoneNumber);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LegalType.Real:
|
||||
if (!request.RealParty.IsAuth)
|
||||
{
|
||||
var realCommand = request.RealParty;
|
||||
var personalContractingParty = _context.PersonalContractingParties
|
||||
.FirstOrDefault(x => x.Nationalcode == realCommand.NationalCode);
|
||||
if (personalContractingParty is {IsAuthenticated:false})
|
||||
{
|
||||
personalContractingParty.UnAuthenticateRealEdit(realCommand.FName, realCommand.LName,
|
||||
realCommand.FatherName, realCommand.IdNumber, personalContractingParty.IdNumberSeri,
|
||||
personalContractingParty.IdNumberSerial, realCommand.BirthDateFa, realCommand.Gender,
|
||||
realCommand.PhoneNumber);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
|
||||
var extenstionTemp = await _institutionExtensionTemp.Find(x => x.Id == request.TempId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (extenstionTemp == null)
|
||||
{
|
||||
throw new BadRequestException("دیتای درخواست شده نامعتبر است");
|
||||
}
|
||||
|
||||
|
||||
var prevInstitutionContracts = await _context.InstitutionContractSet
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.ThenInclude(institutionContractWorkshopGroup => institutionContractWorkshopGroup.CurrentWorkshops)
|
||||
@@ -2139,6 +2178,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
var institutionContractTemp = await _institutionExtensionTemp.Find(x => x.Id == request.TemporaryId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (institutionContractTemp == null)
|
||||
throw new BadRequestException("اطلاعات وارد شده نامعتبر است");
|
||||
var selectedDuration = institutionContractTemp.Duration switch
|
||||
|
||||
@@ -15,268 +15,272 @@ namespace CompanyManagment.EFCore.Services;
|
||||
|
||||
public class UidService : IUidService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IAuthorizedPersonApplication _authorizedPersonApplication;
|
||||
private readonly IAuthorizedBankDetailsApplication _authorizedBankDetailsApplication;
|
||||
private const string BaseUrl = "https://json-api.uid.ir/api/";
|
||||
|
||||
public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IAuthorizedPersonApplication _authorizedPersonApplication;
|
||||
private readonly IAuthorizedBankDetailsApplication _authorizedBankDetailsApplication;
|
||||
private const string BaseUrl = "https://json-api.uid.ir/api/";
|
||||
|
||||
public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
|
||||
public const string BusinessId = "98ed67ca-d441-4978-a748-e8bebce010eb";
|
||||
|
||||
|
||||
public UidService(IAuthorizedPersonApplication authorizedPersonApplication, IAuthorizedBankDetailsApplication authorizedBankDetailsApplication)
|
||||
{
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(BaseUrl),
|
||||
Timeout = new TimeSpan(0, 0, 12)
|
||||
};
|
||||
_authorizedPersonApplication = authorizedPersonApplication;
|
||||
_authorizedBankDetailsApplication = authorizedBankDetailsApplication;
|
||||
}
|
||||
|
||||
public async Task<PersonalInfoResponse> GetPersonalInfo(string nationalCode, string birthDate)
|
||||
{
|
||||
// First check if person exists in database
|
||||
var existingPerson = _authorizedPersonApplication.GetByNationalCode(nationalCode);
|
||||
if (existingPerson != null)
|
||||
{
|
||||
if (birthDate !=existingPerson.BirthDate )
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(13, "تاریخ تولد وارد با کد ملی تطابق ندارد")));
|
||||
}
|
||||
// Return data from database instead of calling API
|
||||
return CreatePersonalInfoResponseFromDatabase(existingPerson);
|
||||
}
|
||||
public UidService(IAuthorizedPersonApplication authorizedPersonApplication,
|
||||
IAuthorizedBankDetailsApplication authorizedBankDetailsApplication)
|
||||
{
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(BaseUrl),
|
||||
Timeout = new TimeSpan(0, 0, 20)
|
||||
};
|
||||
_authorizedPersonApplication = authorizedPersonApplication;
|
||||
_authorizedBankDetailsApplication = authorizedBankDetailsApplication;
|
||||
}
|
||||
|
||||
// If not found in database, call UID API
|
||||
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<PersonalInfoResponse> GetPersonalInfo(string nationalCode, string birthDate)
|
||||
{
|
||||
// First check if person exists in database
|
||||
var existingPerson = _authorizedPersonApplication.GetByNationalCode(nationalCode);
|
||||
if (existingPerson != null)
|
||||
{
|
||||
if (birthDate != existingPerson.BirthDate)
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default),
|
||||
new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(13, "تاریخ تولد وارد با کد ملی تطابق ندارد")));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
|
||||
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
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 data from database instead of calling API
|
||||
return CreatePersonalInfoResponseFromDatabase(existingPerson);
|
||||
}
|
||||
|
||||
// ذخیره اطلاعات در جدول AuthorizedPerson
|
||||
await SaveAuthorizedPersonData(responseResult, nationalCode, birthDate);
|
||||
// If not found in database, call UID API
|
||||
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");
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(14, "")));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
|
||||
|
||||
private PersonalInfoResponse CreatePersonalInfoResponseFromDatabase(AuthorizedPersonViewModel person)
|
||||
{
|
||||
var basicInfo = new UidBasicInformation
|
||||
{
|
||||
FirstName = person.FirstName,
|
||||
LastName = person.LastName,
|
||||
FatherName = person.FatherName,
|
||||
Gender = person.Gender
|
||||
};
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
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();
|
||||
}
|
||||
|
||||
var identificationInfo = new IdentificationInformation(
|
||||
person.NationalCode,
|
||||
person.BirthDate,
|
||||
person.ShenasnameSeri,
|
||||
person.ShenasnameSerial,
|
||||
person.ShenasnamehNumber
|
||||
);
|
||||
// ذخیره اطلاعات در جدول AuthorizedPerson
|
||||
await SaveAuthorizedPersonData(responseResult, nationalCode, birthDate);
|
||||
|
||||
var registrationStatus = new RegistrationStatus
|
||||
{
|
||||
DeathStatus = person.DeathStatus
|
||||
};
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(14, "")));
|
||||
}
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
private PersonalInfoResponse CreatePersonalInfoResponseFromDatabase(AuthorizedPersonViewModel person)
|
||||
{
|
||||
var basicInfo = new UidBasicInformation
|
||||
{
|
||||
FirstName = person.FirstName,
|
||||
LastName = person.LastName,
|
||||
FatherName = person.FatherName,
|
||||
Gender = person.Gender
|
||||
};
|
||||
|
||||
return new PersonalInfoResponse(basicInfo, identificationInfo, registrationStatus, responseContext);
|
||||
}
|
||||
var identificationInfo = new IdentificationInformation(
|
||||
person.NationalCode,
|
||||
person.BirthDate,
|
||||
person.ShenasnameSeri,
|
||||
person.ShenasnameSerial,
|
||||
person.ShenasnamehNumber
|
||||
);
|
||||
|
||||
private async Task SaveAuthorizedPersonData(PersonalInfoResponse response, string nationalCode, string birthDate)
|
||||
{
|
||||
if (response?.BasicInformation == null || response.ResponseContext?.Status?.Code != 0)
|
||||
return;
|
||||
var registrationStatus = new RegistrationStatus
|
||||
{
|
||||
DeathStatus = person.DeathStatus
|
||||
};
|
||||
|
||||
var command = new CreateAuthorizedPerson
|
||||
{
|
||||
NationalCode = nationalCode,
|
||||
FirstName = response.BasicInformation.FirstName ?? "",
|
||||
LastName = response.BasicInformation.LastName ?? "",
|
||||
FatherName = response.BasicInformation.FatherName ?? "",
|
||||
BirthDate = birthDate,
|
||||
Gender = response.BasicInformation.Gender ?? "",
|
||||
DeathStatus = response.RegistrationStatus?.DeathStatus ?? "",
|
||||
ShenasnameSeri = response.IdentificationInformation?.ShenasnameSeri ?? "",
|
||||
ShenasnameSerial = response.IdentificationInformation?.ShenasnameSerial ?? "",
|
||||
ShenasnamehNumber = response.IdentificationInformation?.ShenasnamehNumber ?? ""
|
||||
};
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
|
||||
_authorizedPersonApplication.CreateFromUidResponse(command);
|
||||
}
|
||||
return new PersonalInfoResponse(basicInfo, identificationInfo, registrationStatus, responseContext);
|
||||
}
|
||||
|
||||
public async Task<MatchMobileWithNationalCodeResponse> 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");
|
||||
private async Task SaveAuthorizedPersonData(PersonalInfoResponse response, string nationalCode, string birthDate)
|
||||
{
|
||||
if (response?.BasicInformation == null || response.ResponseContext?.Status?.Code != 0)
|
||||
return;
|
||||
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var command = new CreateAuthorizedPerson
|
||||
{
|
||||
NationalCode = nationalCode,
|
||||
FirstName = response.BasicInformation.FirstName ?? "",
|
||||
LastName = response.BasicInformation.LastName ?? "",
|
||||
FatherName = response.BasicInformation.FatherName ?? "",
|
||||
BirthDate = birthDate,
|
||||
Gender = response.BasicInformation.Gender ?? "",
|
||||
DeathStatus = response.RegistrationStatus?.DeathStatus ?? "",
|
||||
ShenasnameSeri = response.IdentificationInformation?.ShenasnameSeri ?? "",
|
||||
ShenasnameSerial = response.IdentificationInformation?.ShenasnameSerial ?? "",
|
||||
ShenasnamehNumber = response.IdentificationInformation?.ShenasnamehNumber ?? ""
|
||||
};
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
_authorizedPersonApplication.CreateFromUidResponse(command);
|
||||
}
|
||||
|
||||
public async Task<IbanInquiryResponse> IbanInquiry(string iban)
|
||||
{
|
||||
// First check if bank details exist in database
|
||||
var existingBankDetails = _authorizedBankDetailsApplication.GetByIban(iban);
|
||||
if (existingBankDetails != null)
|
||||
{
|
||||
// Return data from database instead of calling API
|
||||
return CreateIbanInquiryResponseFromDatabase(existingBankDetails);
|
||||
}
|
||||
public async Task<MatchMobileWithNationalCodeResponse> 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");
|
||||
|
||||
// If not found in database, call UID API
|
||||
var request = new
|
||||
{
|
||||
iban,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/iban/v2", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<IbanInquiryResponse>();
|
||||
|
||||
if (responseResult.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var entity = new CreateAuthorizedBankDetails
|
||||
{
|
||||
IBan = iban,
|
||||
AccountNumber = responseResult?.AccountBasicInformation?.AccountNumber ?? "",
|
||||
BankName = responseResult?.AccountBasicInformation?.BankInformation?.BankName ?? "",
|
||||
OwnersList = responseResult?.Owners.Select(x=> new CreateAuthorizedBankDetailsOwner()
|
||||
{
|
||||
FName = x.FirstName,
|
||||
LName = x.LastName,
|
||||
NationalIdentifier = x.NationalIdentifier,
|
||||
CustomerType = x.CustomerType
|
||||
}).ToList() ?? []
|
||||
};
|
||||
_authorizedBankDetailsApplication.Create(entity);
|
||||
}
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
ResponseContext = new ResponseContext(new UidStatus(14, "خطا در دریافت اطلاعات از سرویس"))
|
||||
};
|
||||
}
|
||||
}
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
private IbanInquiryResponse CreateIbanInquiryResponseFromDatabase(AuthorizedBankDetailsViewModel bankDetails)
|
||||
{
|
||||
var accountBasicInfo = new IbanInquiryAccountBasicInformation
|
||||
{
|
||||
Iban = bankDetails.IBan,
|
||||
AccountNumber = bankDetails.AccountNumber,
|
||||
BankInformation = new IbanInquiryBankInformation
|
||||
{
|
||||
BankName = bankDetails.BankName
|
||||
},
|
||||
AccountStatus = "Active"
|
||||
};
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
var owners = new List<IbanInquiryOwner>();
|
||||
|
||||
// Add owner information if available
|
||||
if (bankDetails.Owners.Any())
|
||||
{
|
||||
var owner = bankDetails.Owners.First();
|
||||
owners.Add(new IbanInquiryOwner
|
||||
{
|
||||
NationalIdentifier = owner.NationalIdentifier,
|
||||
FirstName = owner.FName,
|
||||
LastName = owner.LName,
|
||||
CustomerType = owner.CustomerType
|
||||
});
|
||||
}
|
||||
public async Task<IbanInquiryResponse> IbanInquiry(string iban)
|
||||
{
|
||||
// First check if bank details exist in database
|
||||
var existingBankDetails = _authorizedBankDetailsApplication.GetByIban(iban);
|
||||
if (existingBankDetails != null)
|
||||
{
|
||||
// Return data from database instead of calling API
|
||||
return CreateIbanInquiryResponseFromDatabase(existingBankDetails);
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
// If not found in database, call UID API
|
||||
var request = new
|
||||
{
|
||||
iban,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
AccountBasicInformation = accountBasicInfo,
|
||||
Owners = owners,
|
||||
ResponseContext = responseContext
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/iban/v2", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<IbanInquiryResponse>();
|
||||
|
||||
public async Task<AccountToIbanResponse> AccountToIban(string accountNumber, UidBanks bank)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
accountNumber,
|
||||
bank,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("account-to-iban", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<AccountToIbanResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
if (responseResult.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var entity = new CreateAuthorizedBankDetails
|
||||
{
|
||||
IBan = iban,
|
||||
AccountNumber = responseResult?.AccountBasicInformation?.AccountNumber ?? "",
|
||||
BankName = responseResult?.AccountBasicInformation?.BankInformation?.BankName ?? "",
|
||||
OwnersList = responseResult?.Owners.Select(x => new CreateAuthorizedBankDetailsOwner()
|
||||
{
|
||||
FName = x.FirstName,
|
||||
LName = x.LastName,
|
||||
NationalIdentifier = x.NationalIdentifier,
|
||||
CustomerType = x.CustomerType
|
||||
}).ToList() ?? []
|
||||
};
|
||||
_authorizedBankDetailsApplication.Create(entity);
|
||||
}
|
||||
|
||||
public async Task<CardToNumberResponse> CardToIban(string cardNumber)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
cardNumber,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/card", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<CardToNumberResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
ResponseContext = new ResponseContext(new UidStatus(14, "خطا در دریافت اطلاعات از سرویس"))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private IbanInquiryResponse CreateIbanInquiryResponseFromDatabase(AuthorizedBankDetailsViewModel bankDetails)
|
||||
{
|
||||
var accountBasicInfo = new IbanInquiryAccountBasicInformation
|
||||
{
|
||||
Iban = bankDetails.IBan,
|
||||
AccountNumber = bankDetails.AccountNumber,
|
||||
BankInformation = new IbanInquiryBankInformation
|
||||
{
|
||||
BankName = bankDetails.BankName
|
||||
},
|
||||
AccountStatus = "Active"
|
||||
};
|
||||
|
||||
var owners = new List<IbanInquiryOwner>();
|
||||
|
||||
// Add owner information if available
|
||||
if (bankDetails.Owners.Any())
|
||||
{
|
||||
var owner = bankDetails.Owners.First();
|
||||
owners.Add(new IbanInquiryOwner
|
||||
{
|
||||
NationalIdentifier = owner.NationalIdentifier,
|
||||
FirstName = owner.FName,
|
||||
LastName = owner.LName,
|
||||
CustomerType = owner.CustomerType
|
||||
});
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
AccountBasicInformation = accountBasicInfo,
|
||||
Owners = owners,
|
||||
ResponseContext = responseContext
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<AccountToIbanResponse> AccountToIban(string accountNumber, UidBanks bank)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
accountNumber,
|
||||
bank,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("account-to-iban", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<AccountToIbanResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
public async Task<CardToNumberResponse> CardToIban(string cardNumber)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
cardNumber,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/card", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<CardToNumberResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
56
ServiceHost/Areas/Client/Controllers/DashboardController.cs
Normal file
56
ServiceHost/Areas/Client/Controllers/DashboardController.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.ClientDashboard;
|
||||
using CompanyManagment.App.Contracts.Holiday;
|
||||
using CompanyManagment.App.Contracts.HolidayItem;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PersianTools.Core;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
public record ClientDashboardViewModel(List<CalenderViewModel> Calender, int Year,string Month,int Day,string DayOfWeek);
|
||||
|
||||
public class DashboardController:ClientBaseController
|
||||
{
|
||||
private readonly IHolidayItemApplication _holidayItemApplication;
|
||||
|
||||
public DashboardController(IHolidayItemApplication holidayItemApplication)
|
||||
{
|
||||
_holidayItemApplication = holidayItemApplication;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<ClientDashboardViewModel> Index()
|
||||
{
|
||||
var calenderList = new List<CalenderViewModel>();
|
||||
|
||||
var todayGr = DateTime.Today;
|
||||
var todayFa = todayGr.ToFarsi();
|
||||
|
||||
var todayPersian = new PersianDateTime(
|
||||
int.Parse(todayFa.Substring(0, 4)),
|
||||
int.Parse(todayFa.Substring(5, 2)),
|
||||
int.Parse(todayFa.Substring(8, 2))
|
||||
);
|
||||
|
||||
var startDate =new PersianDateTime(todayGr.AddDays(-3));
|
||||
var endDate =new PersianDateTime(todayGr.AddDays(3));
|
||||
|
||||
|
||||
for (var day = startDate; day <= endDate; day = day.AddDays(1))
|
||||
{
|
||||
var calenderNewItem = new CalenderViewModel
|
||||
{
|
||||
DayNumber = day.ToString("dd"),
|
||||
IsToday = day.DateTime == todayGr,
|
||||
DayOfWeek = day.DayOfWeek,
|
||||
Holiday = _holidayItemApplication.IsHoliday(day.ToGregorianDateTime()) || day.DayOfWeek== "جمعه"
|
||||
};
|
||||
calenderList.Add(calenderNewItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new ClientDashboardViewModel(calenderList, todayPersian.Year,todayPersian.MonthOfYear,todayPersian.Day,todayPersian.DayOfWeek);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user