feat: add authentication fields and workflow registration retrieval for employers
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.AccessControl;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.ContractAgg;
|
||||
@@ -66,6 +68,11 @@ public class Employer : EntityBase
|
||||
public string SanaPassword { get; private set; }
|
||||
|
||||
public string EmployerNo { get; set; }
|
||||
public bool IsAuth { get; set; }
|
||||
public string IdNumberSerial { get; set; }
|
||||
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
public PersonalContractingParty ContractingParty { get; set; }
|
||||
|
||||
//public List<Workshop> Workshops { get; private set; }
|
||||
@@ -227,4 +234,35 @@ public class Employer : EntityBase
|
||||
this.IsActive = false;
|
||||
this.Address = "false";
|
||||
}
|
||||
|
||||
public void Authentication(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() : new();
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender == _0_Framework.Application.Gender.Male? "مرد" : "زن";
|
||||
this.IsAuth = true;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
|
||||
public void LegalAuthentication(string fName, string lName, string fatherName,string idNumber, string idNumberSeri,
|
||||
string idNumberSerial, string dateOfBirth, Gender gender,string phone)
|
||||
{
|
||||
FName = fName;
|
||||
EmployerLName = lName;
|
||||
this.FatherName = fatherName;
|
||||
this.IdNumberSeri = idNumberSeri;
|
||||
this.IdNumberSerial = idNumberSerial;
|
||||
this.DateOfBirth = !string.IsNullOrWhiteSpace(dateOfBirth) ? dateOfBirth.ToGeorgianDateTime() : new();
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender =gender == _0_Framework.Application.Gender.Male? "مرد" : "زن";
|
||||
this.IsAuth = true;
|
||||
Phone = phone;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Company.Domain.empolyerAgg;
|
||||
|
||||
@@ -69,5 +70,5 @@ public interface IEmployerRepository : IRepository<long, Employer>
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Task<ActionResult<EditEmployerWorkflowRegistration>> GetWorkflowRegistrationForEdit(long employerId, long institutionWorkshopDetailsId);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employer;
|
||||
@@ -146,6 +147,7 @@ public interface IEmployerApplication
|
||||
Task<OperationResult> DeleteWorkflowRegistration(long employerId, long institutionWorkshopDetailsId);
|
||||
|
||||
Task<OperationResult<AuthenticateUserViewModel>> AuthenticateEmployer(string nationalCode, string dateOfBirth, string mobile);
|
||||
Task<ActionResult<EditEmployerWorkflowRegistration>> GetWorkflowRegistrationForEdit(long employerId, long institutionWorkshopDetailsId);
|
||||
}
|
||||
|
||||
public class AuthenticateUserViewModel
|
||||
@@ -330,6 +332,8 @@ public class CreateLegalEmployerWorkflowRegistration
|
||||
/// </summary>
|
||||
public GovernmentSystemInfo GovernmentSystemInfo { get; set; }
|
||||
|
||||
public string IdNumberSeri { get; set; }
|
||||
public string IdNumberSerial { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -401,6 +405,9 @@ public class CreateRealEmployerWorkflowRegistration
|
||||
/// شماره تلفن
|
||||
/// </summary>
|
||||
public string Telephone { get; set; }
|
||||
|
||||
public string IdNumberSeri { get; set; }
|
||||
public string IdNumberSerial { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.UID;
|
||||
@@ -13,6 +14,7 @@ using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Identity.Client;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
@@ -1284,9 +1286,10 @@ public class EmployerApplication : IEmployerApplication
|
||||
return opration.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<List<EmployerSelectListViewModel>> GetSelectList(string search, long id, LegalType? legalType = null)
|
||||
public async Task<List<EmployerSelectListViewModel>> GetSelectList(string search, long id,
|
||||
LegalType? legalType = null)
|
||||
{
|
||||
return await _EmployerRepository.GetSelectList(search, id,legalType);
|
||||
return await _EmployerRepository.GetSelectList(search, id, legalType);
|
||||
}
|
||||
|
||||
async Task<OperationResult<string>> IEmployerApplication.Remove(long id)
|
||||
@@ -1433,6 +1436,7 @@ public class EmployerApplication : IEmployerApplication
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
|
||||
var res = new AuthenticateUserViewModel()
|
||||
{
|
||||
DateOfBirth = dateOfBirth,
|
||||
@@ -1449,6 +1453,12 @@ public class EmployerApplication : IEmployerApplication
|
||||
return op.Succcedded(res);
|
||||
}
|
||||
|
||||
public Task<ActionResult<EditEmployerWorkflowRegistration>> GetWorkflowRegistrationForEdit(long employerId,
|
||||
long institutionWorkshopDetailsId)
|
||||
{
|
||||
return _EmployerRepository.GetWorkflowRegistrationForEdit(employerId, institutionWorkshopDetailsId);
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Employer>> CreateLegalEmployerRegistration(
|
||||
CreateLegalEmployerWorkflowRegistration command, long contractingPartyId)
|
||||
{
|
||||
@@ -1515,6 +1525,11 @@ public class EmployerApplication : IEmployerApplication
|
||||
command.GovernmentSystemInfo.EServiceUsername, command.GovernmentSystemInfo.EServicePassword,
|
||||
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword,
|
||||
command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword);
|
||||
if (command.IsAuth)
|
||||
{
|
||||
legalEmployerData.LegalAuthentication(command.CeoFName,command.CeoLName,command.CeoFatherName,
|
||||
command.CeoIdNumber,command.IdNumberSeri,command.IdNumberSerial,command.CeoDateOfBirth,command.Gender,command.PhoneNumber);
|
||||
}
|
||||
|
||||
await _EmployerRepository.CreateAsync(legalEmployerData);
|
||||
await _EmployerRepository.SaveChangesAsync();
|
||||
@@ -1568,6 +1583,12 @@ public class EmployerApplication : IEmployerApplication
|
||||
command.GovernmentSystemInfo.EServicePassword,
|
||||
command.GovernmentSystemInfo.TaxUsername, command.GovernmentSystemInfo.TaxPassword,
|
||||
command.GovernmentSystemInfo.SanaUsername, command.GovernmentSystemInfo.SanaPassword);
|
||||
if (command.IsAuth)
|
||||
{
|
||||
employerData.Authentication(command.FName, command.LName, command.FatherName, command.IdNumber,
|
||||
command.IdNumberSeri,
|
||||
command.IdNumberSerial, command.DateOfBirth, command.Gender, command.PhoneNumber);
|
||||
}
|
||||
|
||||
await _EmployerRepository.CreateAsync(employerData);
|
||||
await _EmployerRepository.SaveChangesAsync();
|
||||
|
||||
10971
CompanyManagment.EFCore/Migrations/20251014082438_add authenticate columns to employer.Designer.cs
generated
Normal file
10971
CompanyManagment.EFCore/Migrations/20251014082438_add authenticate columns to employer.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addauthenticatecolumnstoemployer : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSeri",
|
||||
table: "Employers",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSerial",
|
||||
table: "Employers",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAuth",
|
||||
table: "Employers",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSeri",
|
||||
table: "Employers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSerial",
|
||||
table: "Employers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAuth",
|
||||
table: "Employers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6779,9 +6779,18 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("IdNumberSeri")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("IdNumberSerial")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsAuth")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("IsLegal")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
@@ -11,6 +11,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Exceptions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OfficeOpenXml.Packaging.Ionic.Zip;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -1029,5 +1032,101 @@ public class EmployerRepository : RepositoryBase<long, Employer>, IEmployerRepos
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ActionResult<EditEmployerWorkflowRegistration>> GetWorkflowRegistrationForEdit(long employerId,
|
||||
long institutionWorkshopDetailsId)
|
||||
{
|
||||
var contractWorkshopInitial = await _context.InstitutionContractWorkshopInitials
|
||||
.Include(x => x.Employers)
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.ThenInclude(x => x.InstitutionContract)
|
||||
.FirstOrDefaultAsync(x => x.id == institutionWorkshopDetailsId);
|
||||
|
||||
if (contractWorkshopInitial == null)
|
||||
throw new BadRequestException("جزئیات کارگاه موسسه یافت نشد");
|
||||
|
||||
if (contractWorkshopInitial.Employers.All(x => x.EmployerId != employerId))
|
||||
{
|
||||
throw new BadRequestException("کارفرمای مورد نظر در این جزئیات کارگاه موسسه یافت نشد");
|
||||
}
|
||||
|
||||
var employer = _context.Employers.FirstOrDefault(x => x.id == employerId);
|
||||
if (employer == null)
|
||||
throw new BadRequestException("کارفرمای مورد نظر در این جزئیات کارگاه موسسه یافت نشد");
|
||||
|
||||
var legalType = employer.IsLegal == "حقوقی" ? LegalType.Legal : LegalType.Real;
|
||||
CreateRealEmployerWorkflowRegistration realEmployer = null;
|
||||
CreateLegalEmployerWorkflowRegistration legalEmployer = null;
|
||||
var governmentSystemInfo = new GovernmentSystemInfo
|
||||
{
|
||||
EServicePassword = employer.EservicePassword,
|
||||
EServiceUsername = employer.EservicePassword,
|
||||
MclPassword = employer.MclsPassword,
|
||||
MclUsername = employer.MclsUserName,
|
||||
SanaUsername = employer.SanaUserName,
|
||||
SanaPassword = employer.SanaPassword,
|
||||
TaxUsername = employer.TaxOfficeUserName,
|
||||
TaxPassword = employer.TaxOfficepassword
|
||||
};
|
||||
if (legalType == LegalType.Real)
|
||||
{
|
||||
realEmployer = new CreateRealEmployerWorkflowRegistration()
|
||||
{
|
||||
FName = employer.FName,
|
||||
LName = employer.LName,
|
||||
IdNumber = employer.IdNumber,
|
||||
DateOfBirth = employer.DateOfBirth.ToFarsi(),
|
||||
PlaceOfIssue = employer.PlaceOfIssue,
|
||||
DateOfIssue = employer.DateOfIssue.ToFarsi(),
|
||||
FatherName = employer.FatherName,
|
||||
Gender = employer.Gender == "مرد" ? Gender.Male : Gender.Female,
|
||||
GovernmentSystemInfo = governmentSystemInfo,
|
||||
IsAuth = employer.IsAuth,
|
||||
PhoneNumber = employer.Phone,
|
||||
IdNumberSeri = employer.IdNumberSeri,
|
||||
IdNumberSerial = employer.IdNumberSerial,
|
||||
NationalCode = employer.Nationalcode,
|
||||
Telephone = employer.AgentPhone
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
legalEmployer = new CreateLegalEmployerWorkflowRegistration()
|
||||
{
|
||||
CompanyName = employer.LName,
|
||||
CeoFName = employer.FName,
|
||||
CeoLName = employer.EmployerLName,
|
||||
NationalId = employer.NationalId,
|
||||
RegisterId = employer.RegisterId,
|
||||
CeoDateOfBirth = employer.DateOfBirth.ToFarsi(),
|
||||
CeoPlaceOfIssue = employer.PlaceOfIssue,
|
||||
CeoDateOfIssue = employer.DateOfIssue.ToFarsi(),
|
||||
CeoFatherName = employer.FatherName,
|
||||
Gender = employer.Gender == "مرد" ? Gender.Male : Gender.Female,
|
||||
GovernmentSystemInfo = governmentSystemInfo,
|
||||
IsAuth = employer.IsAuth,
|
||||
PhoneNumber = employer.Phone,
|
||||
CeoNationalCode = employer.Nationalcode,
|
||||
IdNumberSerial = employer.IdNumberSerial,
|
||||
CeoIdNumber = employer.IdNumber,
|
||||
IdNumberSeri = employer.IdNumberSeri,
|
||||
TelephoneNumber = employer.IdNumber
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
var res = new EditEmployerWorkflowRegistration()
|
||||
{
|
||||
EmployerId = employerId,
|
||||
ContractingPartyId = contractWorkshopInitial.WorkshopGroup.InstitutionContract.ContractingPartyId,
|
||||
InstitutionContractId = contractWorkshopInitial.WorkshopGroup.InstitutionContractId,
|
||||
LegalType = legalType,
|
||||
InstitutionWorkshopInitialId = contractWorkshopInitial.id,
|
||||
RealEmployer = realEmployer,
|
||||
LegalEmployer = legalEmployer,
|
||||
|
||||
};
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -79,6 +79,12 @@ namespace ServiceHost.Areas.Admin.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<ActionResult<EditEmployerWorkflowRegistration>> GetEmployerForEdit(long employerId, long institutionWorkshopDetailsId)
|
||||
{
|
||||
var result = await _employerApplication.GetWorkflowRegistrationForEdit(employerId, institutionWorkshopDetailsId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// حذف کارفرما از گردش کار ثبت نام
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user