@using Shared.DTOs @page "/Verification/{ID:int}" @inject HttpClient _hc @inject NavigationManager nav احراز هویت لطفا کد ارسالی را وارد نمایید احراز هویت کد تائید احراز @alertMessage اتمام عملیات کد ارسال نشد؟ ارسال مجدد @code { bool successfull = false; // alert AlertColor alertColor = AlertColor.Primary; IconName alertIconName = IconName.CheckCircleFill; bool Hidealert = true; string alertMessage = ""; [Parameter] public int ID { get; set; } [SupplyParameterFromForm] public VerificationCodeDto? VerificationCodeModel { get; set; } = new VerificationCodeDto(); protected override async Task OnParametersSetAsync() { var request = await _hc.GetAsync($"Verification/GetVerification/{ID}"); if (request.IsSuccessStatusCode) { VerificationCodeModel = await request.Content.ReadFromJsonAsync(); } else { nav.NavigateTo($"/"); } await base.OnParametersSetAsync(); } } @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) { ShowDangerAlert("کد احراز صحیح نمی باشد"); } else { var request = await _hc.PostAsJsonAsync($"Verification/Submit", VerificationCodeModel); if (request.IsSuccessStatusCode) { var status = await request.Content.ReadFromJsonAsync(); if (status) { if (VerificationCodeModel.Type == "CompanyRegistration") nav.NavigateTo("/Sign-in/VerificationRegister"); else if (VerificationCodeModel.Type == "ForgetPassword") nav.NavigateTo("/Sign-in/VerificationFrogetPass"); else nav.NavigateTo("/"); } else { ShowDangerAlert("خطای سیستمی رخ داده"); } } else { ShowDangerAlert(await request.Content.ReadFromJsonAsync()); } } } private void ShowSuccessAlert(string msg) { Hidealert = false; alertColor = AlertColor.Success; alertIconName = IconName.CheckCircleFill; alertMessage = msg; } private void ShowDangerAlert(string msg) { Hidealert = false; alertColor = AlertColor.Danger; alertIconName = IconName.ExclamationTriangleFill; alertMessage = msg; } private async Task EndForm() { if (!successfull) await _hc.DeleteAsync($"Verification/Remove/{VerificationCodeModel?.ID}"); nav.NavigateTo("/"); } }