From cba0d3ba2e461332487989f75d15eb3a6fc32adb Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Tue, 16 Apr 2024 12:23:29 +0330 Subject: [PATCH] ... --- Back/Back.csproj | 3 +-- Back/Controllers/VerificationController.cs | 28 ++++++++++++++++++---- Back/Program.cs | 3 +++ Back/Services/ServValidatinMsg.cs | 17 +++++++++++-- TaxPayerFull/Pages/Verification.razor | 28 +++++++--------------- TaxPayerFull/Program.cs | 5 ++-- 6 files changed, 55 insertions(+), 29 deletions(-) diff --git a/Back/Back.csproj b/Back/Back.csproj index ac6c0cd..00e888c 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -25,7 +25,6 @@ - @@ -34,7 +33,7 @@ - ..\..\Dlls\Service.dll + ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll diff --git a/Back/Controllers/VerificationController.cs b/Back/Controllers/VerificationController.cs index f8e4a68..ec00b54 100644 --- a/Back/Controllers/VerificationController.cs +++ b/Back/Controllers/VerificationController.cs @@ -12,11 +12,11 @@ namespace Back.Controllers [ApiController] public class VerificationController : ControllerBase { - //private readonly ServValidatinMsg _servValidatinMsg; + private readonly ServValidatinMsg _servValidatinMsg; private readonly GetVerificationValidation _getVerificationValidation; - public VerificationController(/*ServValidatinMsg servValidatinMsg, */GetVerificationValidation getVerificationValidation) + public VerificationController(ServValidatinMsg servValidatinMsg, GetVerificationValidation getVerificationValidation) { - //_servValidatinMsg = servValidatinMsg; + _servValidatinMsg = servValidatinMsg; _getVerificationValidation = getVerificationValidation; } @@ -40,7 +40,27 @@ namespace Back.Controllers [AllowAnonymous] public async Task> Submit(VerificationCodeDto item) { - return Ok(false); + var VerificationCode= await _servValidatinMsg.GetVerificationCode(item.ID); + if (VerificationCode==null) + return NotFound("آیتمی یافت نشد"); + + if (VerificationCode.Code==item.Code) + { + if (VerificationCode.prm == item.prm && VerificationCode.val == item.val && VerificationCode.Type == item.Type) + { + switch (VerificationCode.Type) + { + case "NewTicketNoAuthentication": + return Ok(_servValidatinMsg.SubmittedTicket(VerificationCode)); + default: + return BadRequest("این نوع احراز تعریف نشده"); + } + } + else return BadRequest("اطلاعات شما منطبق با سامانه نیست"); + + } + else return BadRequest("کد احراز صحیح نمی باشد"); + } } } diff --git a/Back/Program.cs b/Back/Program.cs index a2bd173..01e7e56 100644 --- a/Back/Program.cs +++ b/Back/Program.cs @@ -24,6 +24,9 @@ builder.Services.AddScoped(); builder.Services.AddScoped (); builder.Services.AddScoped < ServValidatinMsg>(); builder.Services.AddScoped (); +builder.Services.AddScoped(); + + string origins = "OriginTaxPayer"; builder.Services.AddCors(options => { diff --git a/Back/Services/ServValidatinMsg.cs b/Back/Services/ServValidatinMsg.cs index c53b5a0..9eaa0f6 100644 --- a/Back/Services/ServValidatinMsg.cs +++ b/Back/Services/ServValidatinMsg.cs @@ -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 _verificationCodeRepo; - public ServValidatinMsg(IAsyncRepository verificationCodeRepo) + private readonly IAsyncRepository _ticket; + public ServValidatinMsg(IAsyncRepository verificationCodeRepo, IAsyncRepository ticket) { _verificationCodeRepo = verificationCodeRepo; + _ticket = ticket; } public async Task GetCodeByPrm(string Prm) { @@ -20,6 +23,16 @@ namespace Back.Services { return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync(); } + public async Task 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 GenerateCode(VerificationCode code) { code.Code = Random.Shared.Next(1000, 9000); diff --git a/TaxPayerFull/Pages/Verification.razor b/TaxPayerFull/Pages/Verification.razor index 38273cd..f48889d 100644 --- a/TaxPayerFull/Pages/Verification.razor +++ b/TaxPayerFull/Pages/Verification.razor @@ -42,14 +42,9 @@