...
This commit is contained in:
@@ -9,10 +9,18 @@ namespace Back.Services
|
||||
{
|
||||
private readonly IAsyncRepository<VerificationCode> _verificationCodeRepo;
|
||||
private readonly IAsyncRepository<Ticket> _ticket;
|
||||
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo, IAsyncRepository<Ticket> ticket)
|
||||
private readonly IAsyncRepository<User> _UserRepo;
|
||||
private readonly IAsyncRepository<Company> _CompanyRepo;
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo
|
||||
, IAsyncRepository<Ticket> ticket, IAsyncRepository<User> UserRepo
|
||||
, IAsyncRepository<Company> CompanyRepo, servSendMsg servSendMsg)
|
||||
{
|
||||
_verificationCodeRepo = verificationCodeRepo;
|
||||
_ticket = ticket;
|
||||
_UserRepo = UserRepo;
|
||||
_CompanyRepo = CompanyRepo;
|
||||
_servSendMsg = servSendMsg;
|
||||
}
|
||||
public async Task<VerificationCode> GetCodeByPrm(string Prm)
|
||||
{
|
||||
@@ -37,6 +45,26 @@ namespace Back.Services
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public async Task<bool> SubmittedCompanyRegistration(VerificationCode code)
|
||||
{
|
||||
var user = await _UserRepo.Get(w => w.ID == Convert.ToInt32(code.val) && !w.IsActive).FirstOrDefaultAsync();
|
||||
var company = await _CompanyRepo.Get(w => w.ID == Convert.ToInt32(code.prm) && !w.IsActive).FirstOrDefaultAsync();
|
||||
if (user != null && company != null)
|
||||
{
|
||||
user.IsActive = true;
|
||||
if (await _UserRepo.UpdateAsync(user) != null)
|
||||
{
|
||||
company.IsActive = true;
|
||||
if (await _CompanyRepo.UpdateAsync(company))
|
||||
{
|
||||
_servSendMsg.SuccessfulRegistration(user.Mobile, $"{user.Mobile};{user.Mobile}");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public async Task<int> GenerateCode(VerificationCode code)
|
||||
{
|
||||
code.Code = Random.Shared.Next(1000, 9000);
|
||||
|
Reference in New Issue
Block a user