This commit is contained in:
mmrbnjd
2024-04-17 15:49:34 +03:30
parent f829d80851
commit 3f0a37a08b
27 changed files with 1253 additions and 79 deletions

View File

@@ -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);