From 3f429e05397d530448abb914cc8ed0eae76d34b0 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Sun, 14 Apr 2024 22:19:39 +0330 Subject: [PATCH] ... --- Back/Back.csproj | 2 +- Back/Controllers/TicketController.cs | 10 +-- Back/Data/Models/ValidationCode.cs | 3 +- Back/Services/ServValidatinMsg.cs | 8 +- Shared/DTOs/CTicketNoAuthenticationDto.cs | 4 +- TaxPayerFull/Layout/Contact.razor | 33 +++----- TaxPayerFull/Pages/Verification.razor | 96 ++++++++++++++++++++++- TaxPayerFull/Program.cs | 4 +- 8 files changed, 118 insertions(+), 42 deletions(-) diff --git a/Back/Back.csproj b/Back/Back.csproj index 38e11a4..ac6c0cd 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -34,7 +34,7 @@ - ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll + ..\..\Dlls\Service.dll diff --git a/Back/Controllers/TicketController.cs b/Back/Controllers/TicketController.cs index 7f26338..6abbd71 100644 --- a/Back/Controllers/TicketController.cs +++ b/Back/Controllers/TicketController.cs @@ -37,20 +37,14 @@ namespace Back.Controllers item.CompanyID = pid.Value.ToString(); var Ticket = await _servTicket.NewTicket(item, StatusTicket.unknownPerson); - var code= await _servValidatinMsg.GenerateCode(new VerificationCode + var ID= await _servValidatinMsg.GenerateCode(new VerificationCode { - ID = 0, prm = Ticket.ID.ToString(), val = item.Mobile, Type = "NewTicketNoAuthentication" }); - return Ticket == null ? BadRequest() : Ok(new VerificationCodeDto - { - prm = Ticket.ID.ToString(), - val = item.Mobile, - Type = "NewTicketNoAuthentication" - }); + return Ticket == null ? BadRequest() : Ok(ID); } } } diff --git a/Back/Data/Models/ValidationCode.cs b/Back/Data/Models/ValidationCode.cs index 722378d..1f29c9d 100644 --- a/Back/Data/Models/ValidationCode.cs +++ b/Back/Data/Models/ValidationCode.cs @@ -6,8 +6,9 @@ namespace Back.Data.Models { public class VerificationCode { - [Key, DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public int Code { get; set; } public string prm { get; set; } public string val { get; set; } public string Type { get; set; } diff --git a/Back/Services/ServValidatinMsg.cs b/Back/Services/ServValidatinMsg.cs index 41e57fc..87a235e 100644 --- a/Back/Services/ServValidatinMsg.cs +++ b/Back/Services/ServValidatinMsg.cs @@ -22,14 +22,14 @@ namespace Back.Services } public async Task GenerateCode(VerificationCode code) { - code.ID = Random.Shared.Next(1000, 9000); + code.Code = Random.Shared.Next(1000, 9000); while (await GetRegistrationCode(code.ID) != null) - code.ID = Random.Shared.Next(1000, 9000); + code.Code = Random.Shared.Next(1000, 9000); - await _verificationCodeRepo.AddAsync(code); + var indb= await _verificationCodeRepo.AddAsync(code); - return code.ID; + return indb.ID; } } } diff --git a/Shared/DTOs/CTicketNoAuthenticationDto.cs b/Shared/DTOs/CTicketNoAuthenticationDto.cs index 21bf623..77cc452 100644 --- a/Shared/DTOs/CTicketNoAuthenticationDto.cs +++ b/Shared/DTOs/CTicketNoAuthenticationDto.cs @@ -10,10 +10,10 @@ namespace Shared.DTOs public class CTicketNoAuthenticationDto:CTicketDto { [Required] - [StringLength(11)] + [StringLength(11,MinimumLength =11)] public string Mobile { get; set; } [Required] - [StringLength(5)] + [MinLength(4)] public string FullName { get; set; } } } diff --git a/TaxPayerFull/Layout/Contact.razor b/TaxPayerFull/Layout/Contact.razor index 14f6b48..45655b3 100644 --- a/TaxPayerFull/Layout/Contact.razor +++ b/TaxPayerFull/Layout/Contact.razor @@ -1,7 +1,7 @@ @using Front.Pages @using Shared.DTOs @inject HttpClient _hc - +@inject NavigationManager nav
@@ -100,25 +100,18 @@ @functions{ private async Task newTicket(){ - // var request = await _hc.PostAsJsonAsync("Ticket/NewTicketNoAuthentication", model); - // if (request.IsSuccessStatusCode) - // { - // messageStore?.Clear(); - // var res = await request.Content.ReadFromJsonAsync(); - Verification pa = new Verification(); - pa.model = new VerificationCodeDto - { - prm =" Ticket.ID.ToString()", - val = "item.Mobile", - Type = "NewTicketNoAuthentication" - }; - await Task.Run(()=>pa); - // } - // else - // { - // var error = await request.Content.ReadFromJsonAsync>(); - // messageStore?.Add(() => model.Mobile, error); + var request = await _hc.PostAsJsonAsync("Ticket/NewTicketNoAuthentication", model); + if (request.IsSuccessStatusCode) + { + messageStore?.Clear(); + var res = await request.Content.ReadFromJsonAsync(); + nav.NavigateTo($"Verification/{res}"); + } + else + { + var error = await request.Content.ReadFromJsonAsync>(); + messageStore?.Add(() => model.Mobile, error); - // } + } } } diff --git a/TaxPayerFull/Pages/Verification.razor b/TaxPayerFull/Pages/Verification.razor index cd02456..99d514c 100644 --- a/TaxPayerFull/Pages/Verification.razor +++ b/TaxPayerFull/Pages/Verification.razor @@ -1,13 +1,101 @@ @using Shared.DTOs -@page "/Verification/{model}" -

Verification

+@page "/Verification/{ID:int}" + +
+
+
+
+
+ + + + احراز هویت + + @*
+
کد ارسال شده به شماره @Model.Mobile
+
*@ + + + +
+ + کد تائید +
+
+ +@* +
+
+ + +
+ +
*@ + @* + ارسال مجدد + *@ +
+ +
+ + +
+
+
+
+ + +
@code { [Parameter] - public VerificationCodeDto? model { get; set; } + public int ID { get; set; } + + [SupplyParameterFromForm] + public int Code { get; set; } + + public VerificationCodeDto Model { get; set; } protected override async Task OnParametersSetAsync() { - var dfsf = model; await base.OnParametersSetAsync(); } } +@functions{ + + private void Submit() + { + + } +} + + + + + + + + + + + + + diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index 27ef188..44acca9 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -7,9 +7,9 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); -//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");