add: implement reactivation logic for institution contracts and retrieve previous contracts
This commit is contained in:
@@ -159,4 +159,5 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
#endregion
|
||||
|
||||
Task<long> GetIdByInstallmentId(long installmentId);
|
||||
Task<InstitutionContract> GetPreviousContract(long currentInstitutionContractId);
|
||||
}
|
||||
@@ -1608,7 +1608,10 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
}
|
||||
|
||||
institutionContract.SetSigningType(signingType);
|
||||
|
||||
var previousInstitutionContract = await _institutionContractRepository
|
||||
.GetPreviousContract(institutionContract.id);
|
||||
previousInstitutionContract.DeActive();
|
||||
ReActiveAllAfterCreateNew(institutionContract.ContractingPartyId);
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -2834,8 +2834,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
_context.InstitutionContractContactInfos.Add(contactinfo);
|
||||
}
|
||||
}
|
||||
previousInstitutionContract.DeActive();
|
||||
ReActiveAllAfterExtension(contractingParty.id);
|
||||
await SaveChangesAsync();
|
||||
|
||||
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||
@@ -2847,28 +2845,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
return opration.Succcedded();
|
||||
}
|
||||
|
||||
private void ReActiveAllAfterExtension(long contractingPartyId)
|
||||
{
|
||||
var contractingParty = _context.PersonalContractingParties
|
||||
.FirstOrDefault(x=>x.id ==contractingPartyId);
|
||||
|
||||
if (contractingParty != null)
|
||||
{
|
||||
if (contractingParty.IsActiveString == "false")
|
||||
{
|
||||
contractingParty.Active();
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
var employers =
|
||||
_employerRepository.GetEmployerByContracrtingPartyID(contractingPartyId);
|
||||
|
||||
foreach (var employer in employers)
|
||||
{
|
||||
var res = _employerRepository.ActiveAll(employer.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4830,7 +4806,20 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.Where(x => x.Installments.Any(i => i.Id == installmentId))
|
||||
.Select(x => x.id).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<InstitutionContract> GetPreviousContract(long currentInstitutionContractId)
|
||||
{
|
||||
var institutionContract =await _context.InstitutionContractSet
|
||||
.FirstOrDefaultAsync(x=>x.id ==currentInstitutionContractId);
|
||||
if (institutionContract == null)
|
||||
return null;
|
||||
var previousContract = await _context.InstitutionContractSet
|
||||
.Where(x => x.ContractingPartyId == institutionContract.ContractingPartyId)
|
||||
.Where(x => x.ContractStartGr < institutionContract.ContractStartGr)
|
||||
.OrderByDescending(x => x.ContractEndGr)
|
||||
.FirstOrDefaultAsync();
|
||||
return previousContract;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
private readonly IOnlinePayment _onlinePayment;
|
||||
private readonly IFaceEmbeddingService _faceEmbeddingService;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||||
|
||||
|
||||
[BindProperty] public IFormFile File { get; set; }
|
||||
@@ -77,7 +78,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
public IndexModel(IAndroidApkVersionApplication application, IRollCallDomainService rollCallDomainService,
|
||||
CompanyContext context, AccountContext accountContext, IHttpClientFactory httpClientFactory,
|
||||
IOptions<AppSettingConfiguration> appSetting,
|
||||
ITemporaryClientRegistrationApplication clientRegistrationApplication, IOnlinePayment onlinePayment, IFaceEmbeddingService faceEmbeddingService, IAuthHelper authHelper)
|
||||
ITemporaryClientRegistrationApplication clientRegistrationApplication, IOnlinePayment onlinePayment,
|
||||
IFaceEmbeddingService faceEmbeddingService, IAuthHelper authHelper, IInstitutionContractApplication institutionContractApplication)
|
||||
{
|
||||
_application = application;
|
||||
_rollCallDomainService = rollCallDomainService;
|
||||
@@ -88,6 +90,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
_onlinePayment = onlinePayment;
|
||||
_faceEmbeddingService = faceEmbeddingService;
|
||||
_authHelper = authHelper;
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
|
||||
}
|
||||
|
||||
@@ -152,31 +155,60 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
{
|
||||
//await UpdateInstitutionContract();
|
||||
//await UpdateFaceEmbeddingNames();
|
||||
await SetInstitutionContractSigningType();
|
||||
//await SetInstitutionContractSigningType();
|
||||
await ReActivateInstitution();
|
||||
ViewData["message"] = "تومام یک";
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task ReActivateInstitution()
|
||||
{
|
||||
var blueInstitutionContracts = await _context.InstitutionContractSet.Where(x =>
|
||||
x.IsActiveString == "blue").ToListAsync();
|
||||
|
||||
|
||||
var blueContracts = new List<InstitutionContract>();
|
||||
|
||||
foreach (var blueContract in blueInstitutionContracts)
|
||||
{
|
||||
var verifiedContracts = await _context.InstitutionContractSet
|
||||
.Where(x => x.ContractingPartyId == blueContract.ContractingPartyId
|
||||
&& x.VerificationStatus == InstitutionContractVerificationStatus.Verified
|
||||
&& x.ContractStartGr > blueContract.ContractEndGr)
|
||||
.ToListAsync();
|
||||
|
||||
if (verifiedContracts.Any())
|
||||
{
|
||||
blueContracts.Add(blueContract);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var institutionContract in blueContracts)
|
||||
{
|
||||
institutionContract.DeActive();
|
||||
_institutionContractApplication.ReActiveAllAfterCreateNew(institutionContract.ContractingPartyId);
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SetInstitutionContractSigningType()
|
||||
{
|
||||
var query = _context.InstitutionContractSet
|
||||
.Where(x=>x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify);
|
||||
|
||||
|
||||
var otpSigned = query.Where(x=>x.VerifierFullName != null && x.LawId != 0).ToList();
|
||||
.Where(x => x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify);
|
||||
|
||||
|
||||
var otpSigned = query.Where(x => x.VerifierFullName != null && x.LawId != 0).ToList();
|
||||
foreach (var institutionContract in otpSigned)
|
||||
{
|
||||
institutionContract.SetSigningType(InstitutionContractSigningType.OtpBased);
|
||||
}
|
||||
var lagacySigned = query.Where(x=>x.VerifierFullName == null && x.LawId == 0).ToList();
|
||||
|
||||
var lagacySigned = query.Where(x => x.VerifierFullName == null && x.LawId == 0).ToList();
|
||||
foreach (var institutionContract in lagacySigned)
|
||||
{
|
||||
institutionContract.SetSigningType(InstitutionContractSigningType.Legacy);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostShiftDateNew2()
|
||||
@@ -326,6 +358,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
//TranslateCode(result?.ErrorCode);
|
||||
return Page();
|
||||
}
|
||||
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 120)]
|
||||
public async Task<IActionResult> OnPostUploadFrontEnd(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -368,8 +401,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
TempData["Message"] = "فرآیند Deploy شروع شد. لاگ را بررسی کنید.";
|
||||
return RedirectToPage();
|
||||
}
|
||||
return Forbid();
|
||||
|
||||
return Forbid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -395,13 +428,10 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
{
|
||||
contractingPartyIdList.Add(employer.Employer.ContractingPartyId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (contractingPartyIdList.Count > 0)
|
||||
{
|
||||
|
||||
|
||||
if (contractingPartyIdList.Count == 1)
|
||||
{
|
||||
workshop.AddContractingPartyId(contractingPartyIdList[0]);
|
||||
@@ -422,7 +452,6 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
ViewData["message"] = "آی دی های طرف حساب اضافه شد";
|
||||
return Page();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -441,8 +470,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
var content = System.IO.File.ReadAllText(logPath, Encoding.UTF8);
|
||||
return Content(content);
|
||||
}
|
||||
return Content("شما مجاز به دیدن لاگ نیستید");
|
||||
|
||||
return Content("شما مجاز به دیدن لاگ نیستید");
|
||||
}
|
||||
|
||||
|
||||
@@ -1055,7 +1084,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
x.PersonnelCount,
|
||||
x.Price, x.InstitutionContractWorkshopGroupId,
|
||||
group,
|
||||
x.WorkshopId.Value,x.id);
|
||||
x.WorkshopId.Value, x.id);
|
||||
entity.SetEmployers(x.Employers.Select(e => e.EmployerId).ToList());
|
||||
|
||||
return entity;
|
||||
|
||||
Reference in New Issue
Block a user