From ae83e23b1cf6dde4ff429deda1968fa9056de21a Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Tue, 16 Apr 2024 22:56:02 +0330 Subject: [PATCH] end verification --- Back/Back.csproj | 3 +- Back/Controllers/VerificationController.cs | 26 ++++++++++++- Back/Services/ServValidatinMsg.cs | 6 ++- Back/Services/servTicket.cs | 5 ++- TaxPayerFull/Layout/Contact.razor | 44 ++-------------------- TaxPayerFull/Pages/Verification.razor | 31 ++++++++++++--- TaxPayerFull/Program.cs | 4 +- 7 files changed, 67 insertions(+), 52 deletions(-) diff --git a/Back/Back.csproj b/Back/Back.csproj index 00e888c..ac6c0cd 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -25,6 +25,7 @@ + @@ -33,7 +34,7 @@ - ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll + ..\..\Dlls\Service.dll diff --git a/Back/Controllers/VerificationController.cs b/Back/Controllers/VerificationController.cs index ec00b54..dd9c8ab 100644 --- a/Back/Controllers/VerificationController.cs +++ b/Back/Controllers/VerificationController.cs @@ -36,6 +36,16 @@ namespace Back.Controllers val= _getVerificationValidation.verificationCode.val });; } + [HttpGet("ReSend/{ID}")] + [AllowAnonymous] + public async Task ReSend(int ID) + { + var resultValidationmodel = await _getVerificationValidation.ValidateAsync(ID); + if (!resultValidationmodel.IsValid) + return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); + // _getVerificationValidation.verificationCode + return NoContent(); + } [HttpPost("Submit")] [AllowAnonymous] public async Task> Submit(VerificationCodeDto item) @@ -48,13 +58,19 @@ namespace Back.Controllers { if (VerificationCode.prm == item.prm && VerificationCode.val == item.val && VerificationCode.Type == item.Type) { + bool Sucstatus = false; switch (VerificationCode.Type) { case "NewTicketNoAuthentication": - return Ok(_servValidatinMsg.SubmittedTicket(VerificationCode)); + Sucstatus = await _servValidatinMsg.SubmittedTicket(VerificationCode); + break; default: return BadRequest("این نوع احراز تعریف نشده"); } + if (Sucstatus) + await _servValidatinMsg.Delete(VerificationCode); + + return Ok(Sucstatus); } else return BadRequest("اطلاعات شما منطبق با سامانه نیست"); @@ -62,5 +78,13 @@ namespace Back.Controllers else return BadRequest("کد احراز صحیح نمی باشد"); } + [HttpDelete("Remove/{ID}")] + [AllowAnonymous] + public async Task> Remove(int ID) + { + var VerificationCode = await _servValidatinMsg.GetVerificationCode(ID); + await _servValidatinMsg.Delete(VerificationCode); + return NoContent(); + } } } diff --git a/Back/Services/ServValidatinMsg.cs b/Back/Services/ServValidatinMsg.cs index 9eaa0f6..3451948 100644 --- a/Back/Services/ServValidatinMsg.cs +++ b/Back/Services/ServValidatinMsg.cs @@ -23,10 +23,14 @@ namespace Back.Services { return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync(); } + public async Task Delete(VerificationCode model) + { + return await _verificationCodeRepo.DeleteAsync(model); + } public async Task SubmittedTicket(VerificationCode code) { var ticket = await _ticket.Get(w => w.ID == Convert.ToInt32(code.prm)).FirstOrDefaultAsync(); - if (ticket != null) + if (ticket != null && ticket.Status== StatusTicket.unknownPerson) { ticket.Status = StatusTicket.Awaitingreview; return await _ticket.UpdateAsync(ticket); diff --git a/Back/Services/servTicket.cs b/Back/Services/servTicket.cs index 017ab63..a04bf39 100644 --- a/Back/Services/servTicket.cs +++ b/Back/Services/servTicket.cs @@ -24,7 +24,10 @@ namespace Back.Services { try { - var item=await _ticketUnknownPeopleRepo.AddAsync(new TiceketUnknownPeople + var ID= _ticketUnknownPeopleRepo.Get(w=>w.Mobile==Mobile).Select(s=>s.ID).FirstOrDefault(); + if (ID!=null && ID > 0) + return ID; + var item=await _ticketUnknownPeopleRepo.AddAsync(new TiceketUnknownPeople { FullName = FullName, Mobile = Mobile diff --git a/TaxPayerFull/Layout/Contact.razor b/TaxPayerFull/Layout/Contact.razor index c7193d6..0450a12 100644 --- a/TaxPayerFull/Layout/Contact.razor +++ b/TaxPayerFull/Layout/Contact.razor @@ -29,8 +29,6 @@
- -
@@ -73,7 +71,7 @@
- +
@@ -82,25 +80,10 @@ - - - Modal body text goes here. - - - - - - - - @code { - List messages = new List(); - private Modal _modal = default!; - //------------------------------- string type = "NewTicketNoAuthentication"; private EditContext? editContext; [SupplyParameterFromForm] @@ -127,8 +110,7 @@ { messageStore?.Clear(); var res = await request.Content.ReadFromJsonAsync(); - OnShowModalClick(); - // nav.NavigateTo($"Verification/{res}"); + nav.NavigateTo($"Verification/{res}"); } else { @@ -137,28 +119,8 @@ } } - private async Task testhand() - { - ShowMessage(ToastType.Warning); - } - private async Task OnShowModalClick() - { - await _modal.ShowAsync(); - } - private async Task OnHideModalClick() - { - await _modal.HideAsync(); - } - private void ShowMessage(ToastType toastType) => messages.Add(CreateToastMessage(toastType)); - private ToastMessage CreateToastMessage(ToastType toastType) - => new ToastMessage - { - Type = toastType, - Title = "Blazor Bootstrap", - HelpText = $"{DateTime.Now}", - Message = $"Hello, world! This is a toast message. DateTime: {DateTime.Now}", - }; + } diff --git a/TaxPayerFull/Pages/Verification.razor b/TaxPayerFull/Pages/Verification.razor index b1d5816..d1aec77 100644 --- a/TaxPayerFull/Pages/Verification.razor +++ b/TaxPayerFull/Pages/Verification.razor @@ -42,7 +42,6 @@ @@ -81,7 +81,7 @@ @code { - + bool successfull = false; // alert AlertColor alertColor = AlertColor.Primary; IconName alertIconName = IconName.CheckCircleFill; @@ -95,7 +95,6 @@ [SupplyParameterFromForm] public VerificationCodeDto? VerificationCodeModel { get; set; } = new VerificationCodeDto(); - protected override async Task OnParametersSetAsync() { var request = await _hc.GetAsync($"Verification/GetVerification/{ID}"); @@ -114,6 +113,21 @@ } @functions { + private async Task ReSend() + { + + var request = await _hc.GetAsync($"Verification/ReSend/{VerificationCodeModel?.ID}"); + if (request.IsSuccessStatusCode) + { + ShowSuccessAlert("کد مجدد ارسال شد"); + } + else + { + ShowDangerAlert(await request.Content.ReadFromJsonAsync()); + } + + + } private async Task SubmitVerificationCode() { if (VerificationCodeModel.Code < 1000 || VerificationCodeModel.Code > 9000) @@ -129,6 +143,7 @@ if (status) { ShowSuccessAlert("عملیات با موفقیت انجام شد"); + successfull = true; } else { @@ -157,5 +172,11 @@ alertIconName = IconName.ExclamationTriangleFill; alertMessage = msg; } - private async Task EndForm() => nav.NavigateTo("/"); + private async Task EndForm() + { + if (!successfull) + await _hc.DeleteAsync($"Verification/Remove/{VerificationCodeModel?.ID}"); + + nav.NavigateTo("/"); + } } diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index 0d7c9f3..a4dafa0 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -9,9 +9,9 @@ builder.RootComponents.Add("head::after"); builder.Services.AddBlazorBootstrap(); -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");