Merge branch 'Feature/InstitutionContract/add-registration-style' into Main
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
@@ -128,6 +129,64 @@ public interface IEmployerApplication
|
||||
#endregion
|
||||
|
||||
Task<OperationResult> CreateWorkflowRegistration(CreateEmployerWorkflowRegistration command);
|
||||
Task<OperationResult<AuthenticateUserViewModel>> AuthenticateEmployer(string nationalCode, string dateOfBirth, string mobile);
|
||||
}
|
||||
|
||||
public class AuthenticateUserViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// نام
|
||||
/// </summary>
|
||||
public string FName { get; set; }
|
||||
/// <summary>
|
||||
/// نام خانوادگی
|
||||
/// </summary>
|
||||
public string LName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// جنسیت
|
||||
/// </summary>
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///تاریخ تولد
|
||||
/// </summary>
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره همراه
|
||||
/// </summary>
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Security.AccessControl;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.UID;
|
||||
using _0_Framework.Exceptions;
|
||||
using Company.Domain.empolyerAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
@@ -12,6 +13,7 @@ using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using Microsoft.Identity.Client;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -28,13 +30,15 @@ public class EmployerApplication : IEmployerApplication
|
||||
public bool registerIdIsOk = true;
|
||||
public bool nationalIdIsOk = true;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private readonly IUidService _uidService;
|
||||
|
||||
public EmployerApplication(IEmployerRepository employerRepository, IWorkshopRepository workshopRepository,
|
||||
IInstitutionContractRepository institutionContractRepository)
|
||||
IInstitutionContractRepository institutionContractRepository, IUidService uidService)
|
||||
{
|
||||
_EmployerRepository = employerRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_uidService = uidService;
|
||||
}
|
||||
|
||||
public OperationResult Active(long id)
|
||||
@@ -1316,6 +1320,46 @@ public class EmployerApplication : IEmployerApplication
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<OperationResult<AuthenticateUserViewModel>> AuthenticateEmployer(string nationalCode,
|
||||
string dateOfBirth,
|
||||
string mobile)
|
||||
{
|
||||
var op = new OperationResult<AuthenticateUserViewModel>();
|
||||
|
||||
var dateOfBirthGr = dateOfBirth.ToGeorgianDateTime();
|
||||
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
var apiRespons = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
if (apiRespons == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (apiRespons.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiRespons.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
var res = new AuthenticateUserViewModel()
|
||||
{
|
||||
DateOfBirth = dateOfBirthGr,
|
||||
FatherName = apiRespons.BasicInformation.FatherName,
|
||||
FName = apiRespons.BasicInformation.FirstName,
|
||||
Gender = apiRespons.BasicInformation.GenderEnum,
|
||||
IdNumber = apiRespons.IdentificationInformation.ShenasnamehNumber,
|
||||
IdNumberSeri = apiRespons.IdentificationInformation.ShenasnameSeri,
|
||||
IdNumberSerial = apiRespons.IdentificationInformation.ShenasnameSerial,
|
||||
LName = apiRespons.BasicInformation.LastName,
|
||||
NationalCode = nationalCode,
|
||||
Phone = mobile,
|
||||
};
|
||||
return op.Succcedded(res);
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Employer>> CreateLegalEmployerRegistration(
|
||||
CreateLegalEmployerWorkflowRegistration command, long contractingPartyId)
|
||||
{
|
||||
|
||||
@@ -58,5 +58,18 @@ namespace ServiceHost.Areas.Admin.Controllers
|
||||
var result = await _workshopApplication.CreateWorkshopWorkflowRegistration(command);
|
||||
return result;
|
||||
}
|
||||
[HttpPost("auth-employer")]
|
||||
public async Task<ActionResult<OperationResult<AuthenticateUserViewModel>>> AuthenticateEmployer(AuthenticateEmployerWorkflowRequest command)
|
||||
{
|
||||
var result = await _employerApplication.AuthenticateEmployer(command.NationalCode, command.DateOfBirth, command.Mobile);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class AuthenticateEmployerWorkflowRequest
|
||||
{
|
||||
public string NationalCode { get; set; }
|
||||
public string DateOfBirth { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user