...
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@using Common.Dtos.User
|
||||
@using Hushian.Application.Dtos
|
||||
@using Common.Dtos.Exper
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@using Common.Validation
|
||||
@inject UserService userService;
|
||||
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
@@ -13,21 +13,11 @@
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.PhoneNumber" type="text" class="form-control" placeholder="موبایل" />
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Password" type="password" class="form-control" placeholder="کلمه عبور" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
|
||||
@if (model.img != null && model.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@RePassword" type="password" class="form-control" placeholder="تکرار کلمه عبور" />
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button>
|
||||
|
||||
@@ -36,18 +26,43 @@
|
||||
|
||||
|
||||
@code {
|
||||
public AddUserDto model { get; set; } = new();
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
public ADD_ExperDto model { get; set; } = new();
|
||||
public string RePassword { get; set; }
|
||||
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
|
||||
public bool loading { get; set; } = false;
|
||||
}
|
||||
@functions{
|
||||
@functions {
|
||||
|
||||
async Task<bool> Validation()
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FullName))
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را مشخص کنید"));
|
||||
return false;
|
||||
}
|
||||
if (!model.FullName.IsOnlyPersianLetters())
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
|
||||
return false;
|
||||
}
|
||||
if (model.Password!=RePassword)
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Danger, $"کلمه عبور و تکرار آن مشابه نیستند"));
|
||||
return false;
|
||||
}
|
||||
List<string> errors = new();
|
||||
if (!model.Password.CheckLawPassword(ref errors))
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Danger, errors.First()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.FullName) && !string.IsNullOrEmpty(model.PhoneNumber))
|
||||
if (await Validation())
|
||||
{
|
||||
model.PassWord =model.UserName= model.PhoneNumber;
|
||||
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
|
||||
|
||||
loading = true;
|
||||
if (await userService.AddExper(model))
|
||||
{
|
||||
@@ -60,23 +75,23 @@
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
model = new();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
// private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
// {
|
||||
// var file = e.File;
|
||||
// using (var memoryStream = new MemoryStream())
|
||||
// {
|
||||
// await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
// model.img = memoryStream.ToArray();
|
||||
// }
|
||||
// }
|
||||
// private string GetImageSource()
|
||||
// {
|
||||
// if (model.img != null)
|
||||
// {
|
||||
// return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
// }
|
||||
// return string.Empty;
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user