Compare commits

...

5 Commits

4 changed files with 53 additions and 22 deletions

View File

@@ -1340,6 +1340,10 @@ public class EmployerApplication : IEmployerApplication
var workshopDetails = var workshopDetails =
await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(command await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(command
.InstitutionWorkshopInitialId); .InstitutionWorkshopInitialId);
if (workshopDetails.Employers.Any(x => x.EmployerId == employer.id))
{
throw new BadRequestException("این کارفرما قبلا در این کارگاه ثبت شده است");
}
workshopDetails.AddEmployer(employer.id); workshopDetails.AddEmployer(employer.id);
await _institutionContractRepository.SaveChangesAsync(); await _institutionContractRepository.SaveChangesAsync();
@@ -1387,12 +1391,14 @@ public class EmployerApplication : IEmployerApplication
// Get workshop details // Get workshop details
var workshopDetails = var workshopDetails =
await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(institutionWorkshopDetailsId); await _institutionContractRepository
.GetInstitutionWorkshopInitialDetails(institutionWorkshopDetailsId);
if (workshopDetails == null) if (workshopDetails == null)
return operation.Failed("جزئیات کارگاه موسسه یافت نشد"); return operation.Failed("جزئیات کارگاه موسسه یافت نشد");
// Find and remove the employer from workshop details // Find and remove the employer from workshop details
var employerDetail = workshopDetails.Employers.FirstOrDefault(e => e.EmployerId == employerId); var employerDetail = workshopDetails
.Employers.FirstOrDefault(e => e.EmployerId == employerId);
if (employerDetail == null) if (employerDetail == null)
return operation.Failed("کارفرما در لیست کارگاه یافت نشد"); return operation.Failed("کارفرما در لیست کارگاه یافت نشد");
@@ -1400,10 +1406,7 @@ public class EmployerApplication : IEmployerApplication
workshopDetails.Employers.Remove(employerDetail); workshopDetails.Employers.Remove(employerDetail);
await _institutionContractRepository.SaveChangesAsync(); await _institutionContractRepository.SaveChangesAsync();
// Delete the employer
_EmployerRepository.Remove(employerId);
await _EmployerRepository.SaveChangesAsync();
return operation.Succcedded(); return operation.Succcedded();
} }

View File

@@ -318,7 +318,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
command.DailyCompenseation, command.Obligation, command.DailyCompenseation, command.Obligation,
command.TotalAmount, command.ExtensionNo, command.WorkshopManualCount, command.EmployeeManualCount, command.TotalAmount, command.ExtensionNo, command.WorkshopManualCount, command.EmployeeManualCount,
command.Description, command.OfficialCompany, command.TypeOfContract, command.HasValueAddedTax, command.Description, command.OfficialCompany, command.TypeOfContract, command.HasValueAddedTax,
command.ValueAddedTax, [],command.LawId); command.ValueAddedTax, [], command.LawId);
_institutionContractRepository.Create(createContract); _institutionContractRepository.Create(createContract);
_institutionContractRepository.SaveChanges(); _institutionContractRepository.SaveChanges();
@@ -1046,7 +1046,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
command.Workshops.Count.ToString(), command.Workshops.Count.ToString(),
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description, command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
"NotOfficial", "JobRelation", hasValueAddedTax, "NotOfficial", "JobRelation", hasValueAddedTax,
command.TaxAmount, workshopDetails,command.LawId); command.TaxAmount, workshopDetails, command.LawId);
FinancialStatment financialStatement; FinancialStatment financialStatement;
@@ -1139,11 +1139,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (res.IsSuccedded) if (res.IsSuccedded)
CreateContractingPartyAccount(contractingParty.id, res.SendId); CreateContractingPartyAccount(contractingParty.id, res.SendId);
await _institutionContractRepository.SaveChangesAsync();
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName, await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId); entity.PublicId);
await _institutionContractRepository.SaveChangesAsync();
await transaction.CommitAsync(); await transaction.CommitAsync();
return opration.Succcedded(); return opration.Succcedded();
@@ -1153,7 +1153,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<RegistrationWorkflowMainListViewModel>> RegistrationWorkflowMainList() public Task<List<RegistrationWorkflowMainListViewModel>> RegistrationWorkflowMainList()
{ {
@@ -1249,8 +1249,31 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (institutionContract.VerifyCode != code) if (institutionContract.VerifyCode != code)
return op.Failed("کد وارد شده صحیح نمی باشد"); return op.Failed("کد وارد شده صحیح نمی باشد");
var transaction = await _institutionContractRepository.BeginTransactionAsync();
institutionContract.SetPendingWorkflow(); institutionContract.SetPendingWorkflow();
var phone = institutionContract.ContactInfoList.FirstOrDefault(x =>
x.SendSms && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
if (phone !=null)
{
var userPass = contractingParty.IsLegal == "حقیقی"
? contractingParty.Nationalcode
: contractingParty.NationalId;
var createAcc = new RegisterAccount
{
Fullname = contractingParty.LName,
Username = userPass,
Password = userPass,
Mobile = phone.PhoneNumber,
NationalCode = userPass
};
var res = _accountApplication.RegisterClient(createAcc);
if (res.IsSuccedded)
CreateContractingPartyAccount(contractingParty.id, res.SendId);
}
await transaction.CommitAsync();
await _institutionContractRepository.SaveChangesAsync(); await _institutionContractRepository.SaveChangesAsync();
return op.Succcedded(); return op.Succcedded();
} }
@@ -1274,7 +1297,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
RollCallInPerson = services.RollCallInPerson RollCallInPerson = services.RollCallInPerson
}, },
WorkshopName = details.WorkshopName, WorkshopName = details.WorkshopName,
ArchiveCode =newArchiveCode ArchiveCode = newArchiveCode
}; };
return res; return res;
} }
@@ -1290,12 +1313,14 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return await _institutionContractRepository.GetExtensionWorkshops(request); return await _institutionContractRepository.GetExtensionWorkshops(request);
} }
public async Task<InstitutionContractExtensionPlanResponse> GetExtensionInstitutionPlan(InstitutionContractExtensionPlanRequest request) public async Task<InstitutionContractExtensionPlanResponse> GetExtensionInstitutionPlan(
InstitutionContractExtensionPlanRequest request)
{ {
return await _institutionContractRepository.GetExtensionInstitutionPlan(request); return await _institutionContractRepository.GetExtensionInstitutionPlan(request);
} }
public async Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(InstitutionContractExtensionPaymentRequest request) public async Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(
InstitutionContractExtensionPaymentRequest request)
{ {
return await _institutionContractRepository.GetExtensionPaymentMethod(request); return await _institutionContractRepository.GetExtensionPaymentMethod(request);
} }
@@ -1350,8 +1375,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (request.IsAuth) if (request.IsAuth)
{ {
legalContractingParty.LegalAuthentication(request.FName,request.LName,request.FatherName, legalContractingParty.LegalAuthentication(request.FName, request.LName, request.FatherName,
request.IdNumber,null,null,request.BirthDateFa,request.Gender,request.PhoneNumber); request.IdNumber, null, null, request.BirthDateFa, request.Gender, request.PhoneNumber);
} }
await _contractingPartyRepository.CreateAsync(legalContractingParty); await _contractingPartyRepository.CreateAsync(legalContractingParty);
@@ -1396,7 +1421,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (request.IsAuth) if (request.IsAuth)
{ {
personalContractingParty.Authentication(request.FName, request.LName, request.FatherName, personalContractingParty.Authentication(request.FName, request.LName, request.FatherName,
request.IdNumber, null,null, request.BirthDateFa, request.Gender,request.PhoneNumber); request.IdNumber, null, null, request.BirthDateFa, request.Gender, request.PhoneNumber);
} }
await _contractingPartyRepository.CreateAsync(personalContractingParty); await _contractingPartyRepository.CreateAsync(personalContractingParty);
@@ -1513,4 +1538,4 @@ public class WorkshopsAndEmployeeViewModel
public int ArchiveCode { get; set; } public int ArchiveCode { get; set; }
} }
#endregion #endregion

View File

@@ -592,7 +592,7 @@ public class EmployerRepository : RepositoryBase<long, Employer>, IEmployerRepos
var legalTypeValue = legalType == LegalType.Real ? "حقیقی" : "حقوقی"; var legalTypeValue = legalType == LegalType.Real ? "حقیقی" : "حقوقی";
query = query.Where(x => x.IsLegal == legalTypeValue); query = query.Where(x => x.IsLegal == legalTypeValue);
} }
var viewModelQuery = query.Select(x => new EmployerSelectListViewModel() var viewModelQuery = query.Select(x => new EmployerSelectListViewModel()
{ {
Id = x.id, Id = x.id,
@@ -1078,7 +1078,12 @@ public class EmployerRepository : RepositoryBase<long, Employer>, IEmployerRepos
PlaceOfIssue = employer.PlaceOfIssue, PlaceOfIssue = employer.PlaceOfIssue,
DateOfIssue = employer.DateOfIssue.ToFarsi(), DateOfIssue = employer.DateOfIssue.ToFarsi(),
FatherName = employer.FatherName, FatherName = employer.FatherName,
Gender = employer.Gender == "مرد" ? Gender.Male : Gender.Female, Gender = employer.Gender switch
{
null => Gender.None,
"مرد" => Gender.Male,
_ => Gender.Female
},
GovernmentSystemInfo = governmentSystemInfo, GovernmentSystemInfo = governmentSystemInfo,
IsAuth = employer.IsAuth, IsAuth = employer.IsAuth,
PhoneNumber = employer.Phone, PhoneNumber = employer.Phone,
@@ -1110,7 +1115,6 @@ public class EmployerRepository : RepositoryBase<long, Employer>, IEmployerRepos
CeoIdNumber = employer.IdNumber, CeoIdNumber = employer.IdNumber,
IdNumberSeri = employer.IdNumberSeri, IdNumberSeri = employer.IdNumberSeri,
TelephoneNumber = employer.IdNumber TelephoneNumber = employer.IdNumber
}; };
} }
@@ -1123,7 +1127,6 @@ public class EmployerRepository : RepositoryBase<long, Employer>, IEmployerRepos
InstitutionWorkshopInitialId = contractWorkshopInitial.id, InstitutionWorkshopInitialId = contractWorkshopInitial.id,
RealEmployer = realEmployer, RealEmployer = realEmployer,
LegalEmployer = legalEmployer, LegalEmployer = legalEmployer,
}; };
return res; return res;
} }

View File

@@ -1820,7 +1820,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
public async Task<InstitutionContract> GetByPublicIdAsync(Guid id) public async Task<InstitutionContract> GetByPublicIdAsync(Guid id)
{ {
return await _context.InstitutionContractSet.FirstOrDefaultAsync(x => x.PublicId == id); return await _context.InstitutionContractSet.Include(x=>x.ContactInfoList).FirstOrDefaultAsync(x => x.PublicId == id);
} }
public async Task<InstitutionContractExtensionInquiryResult> GetExtensionInquiry(long previousContractId) public async Task<InstitutionContractExtensionInquiryResult> GetExtensionInquiry(long previousContractId)