This commit is contained in:
mmrbnjd
2024-04-16 12:23:29 +03:30
parent 7f5f7d6006
commit cba0d3ba2e
6 changed files with 55 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
using Back.Data.Contracts;
using Back.Common.Enums;
using Back.Data.Contracts;
using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
@@ -7,9 +8,11 @@ namespace Back.Services
public class ServValidatinMsg
{
private readonly IAsyncRepository<VerificationCode> _verificationCodeRepo;
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo)
private readonly IAsyncRepository<Ticket> _ticket;
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo, IAsyncRepository<Ticket> ticket)
{
_verificationCodeRepo = verificationCodeRepo;
_ticket = ticket;
}
public async Task<VerificationCode> GetCodeByPrm(string Prm)
{
@@ -20,6 +23,16 @@ namespace Back.Services
{
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
}
public async Task<bool> SubmittedTicket(VerificationCode code)
{
var ticket = await _ticket.Get(w => w.ID == Convert.ToInt32(code.prm)).FirstOrDefaultAsync();
if (ticket != null)
{
ticket.Status = StatusTicket.Awaitingreview;
return await _ticket.UpdateAsync(ticket);
}
return false;
}
public async Task<int> GenerateCode(VerificationCode code)
{
code.Code = Random.Shared.Next(1000, 9000);