...
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
using Back.Common.Enums;
|
using Back.Common.Enums;
|
||||||
using Back.Data.Models;
|
using Back.Data.Models;
|
||||||
|
using Back.Services;
|
||||||
|
using Back.Validations;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Shared.DTOs;
|
using Shared.DTOs;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace Back.Controllers
|
namespace Back.Controllers
|
||||||
{
|
{
|
||||||
@@ -12,12 +15,42 @@ namespace Back.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class TicketController : ControllerBase
|
public class TicketController : ControllerBase
|
||||||
{
|
{
|
||||||
|
private readonly MobileValidation _mobilevalidation;
|
||||||
|
private readonly servTicket _servTicket;
|
||||||
|
private readonly ServValidatinMsg _servValidatinMsg;
|
||||||
|
public TicketController(MobileValidation mobilevalidation, servTicket servTicket, ServValidatinMsg servValidatinMsg)
|
||||||
|
{
|
||||||
|
_mobilevalidation = mobilevalidation;
|
||||||
|
_servTicket = servTicket;
|
||||||
|
_servValidatinMsg = servValidatinMsg;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("NewTicketNoAuthentication")]
|
[HttpPost("NewTicketNoAuthentication")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
||||||
{
|
{
|
||||||
return Ok();
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(item.Mobile);
|
||||||
|
if (!resultValidationmodel.IsValid)
|
||||||
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
var pid=await _servTicket.NewPepole(item.FullName,item.Mobile);
|
||||||
|
item.CompanyID = pid.Value.ToString();
|
||||||
|
var Ticket = await _servTicket.NewTicket(item, StatusTicket.unknownPerson);
|
||||||
|
|
||||||
|
var code= 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"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@ builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>))
|
|||||||
builder.Services.AddScoped<Back.Services.ServBase>();
|
builder.Services.AddScoped<Back.Services.ServBase>();
|
||||||
builder.Services.AddScoped<MobileValidation> ();
|
builder.Services.AddScoped<MobileValidation> ();
|
||||||
builder.Services.AddScoped<Service.Main>();
|
builder.Services.AddScoped<Service.Main>();
|
||||||
|
builder.Services.AddScoped<servTicket > ();
|
||||||
|
builder.Services.AddScoped < ServValidatinMsg>();
|
||||||
string origins = "OriginTaxPayer";
|
string origins = "OriginTaxPayer";
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
35
Back/Services/ServValidatinMsg.cs
Normal file
35
Back/Services/ServValidatinMsg.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Back.Data.Contracts;
|
||||||
|
using Back.Data.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Back.Services
|
||||||
|
{
|
||||||
|
public class ServValidatinMsg
|
||||||
|
{
|
||||||
|
private readonly IAsyncRepository<VerificationCode> _verificationCodeRepo;
|
||||||
|
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo)
|
||||||
|
{
|
||||||
|
_verificationCodeRepo = verificationCodeRepo;
|
||||||
|
}
|
||||||
|
public async Task<VerificationCode> GetCodeByPrm(string Prm)
|
||||||
|
{
|
||||||
|
return await _verificationCodeRepo.Get(w => w.prm == Prm).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task<VerificationCode> GetRegistrationCode(int ID)
|
||||||
|
{
|
||||||
|
return await _verificationCodeRepo.Get(w => w.ID == ID).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
public async Task<int> GenerateCode(VerificationCode code)
|
||||||
|
{
|
||||||
|
code.ID = Random.Shared.Next(1000, 9000);
|
||||||
|
while (await GetRegistrationCode(code.ID) != null)
|
||||||
|
code.ID = Random.Shared.Next(1000, 9000);
|
||||||
|
|
||||||
|
|
||||||
|
await _verificationCodeRepo.AddAsync(code);
|
||||||
|
|
||||||
|
return code.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
104
Back/Services/servTicket.cs
Normal file
104
Back/Services/servTicket.cs
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
using Back.Common;
|
||||||
|
using Back.Common.Enums;
|
||||||
|
using Back.Data.Contracts;
|
||||||
|
using Back.Data.Models;
|
||||||
|
using Shared.DTOs;
|
||||||
|
|
||||||
|
namespace Back.Services
|
||||||
|
{
|
||||||
|
public class servTicket
|
||||||
|
{
|
||||||
|
private readonly IAsyncRepository<TiceketUnknownPeople> _ticketUnknownPeopleRepo;
|
||||||
|
private readonly IAsyncRepository<Ticket> _ticketRepo;
|
||||||
|
private readonly IAsyncRepository<SubTicket> _subticketRepo;
|
||||||
|
public servTicket(IAsyncRepository<TiceketUnknownPeople> ticketUnknownPeopleRepo
|
||||||
|
,IAsyncRepository<Ticket> ticketRepo
|
||||||
|
,IAsyncRepository<SubTicket> subticketRepo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_ticketUnknownPeopleRepo = ticketUnknownPeopleRepo;
|
||||||
|
_ticketRepo = ticketRepo;
|
||||||
|
_subticketRepo = subticketRepo;
|
||||||
|
}
|
||||||
|
public async Task<int?> NewPepole(string FullName, string Mobile)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var item=await _ticketUnknownPeopleRepo.AddAsync(new TiceketUnknownPeople
|
||||||
|
{
|
||||||
|
FullName = FullName,
|
||||||
|
Mobile = Mobile
|
||||||
|
});
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewPepole",
|
||||||
|
// Value = JsonConvert.SerializeObject(item),
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "User"
|
||||||
|
//});
|
||||||
|
return item.ID;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewPepole",
|
||||||
|
// Value = ex.Message,
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task<Ticket?> NewTicket(CTicketDto item, StatusTicket status = StatusTicket.Awaitingreview)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ticket=await _ticketRepo.AddAsync(new Ticket
|
||||||
|
{
|
||||||
|
CompanyIDOrMobile = item.CompanyID,
|
||||||
|
CreateDate = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
CreateTime = DateTime.Now.ToString("hh:mm tt"),
|
||||||
|
Title = item.Title,
|
||||||
|
Status = status
|
||||||
|
});
|
||||||
|
await _subticketRepo.AddAsync(new SubTicket
|
||||||
|
{
|
||||||
|
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
Time = DateTime.Now.ToString("hh:mm tt"),
|
||||||
|
TicketID = ticket.ID,
|
||||||
|
Text = item.Text,
|
||||||
|
Type = SideType.Customer
|
||||||
|
});
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewTicket",
|
||||||
|
// Value = JsonConvert.SerializeObject(item),
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "User"
|
||||||
|
//});
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewTicket",
|
||||||
|
// Value = ex.Message,
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,7 @@ namespace Shared.DTOs
|
|||||||
{
|
{
|
||||||
public class CTicketDto
|
public class CTicketDto
|
||||||
{
|
{
|
||||||
public string CompanyID { get; set; }
|
public string? CompanyID { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@@ -10,8 +10,10 @@ namespace Shared.DTOs
|
|||||||
public class CTicketNoAuthenticationDto:CTicketDto
|
public class CTicketNoAuthenticationDto:CTicketDto
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
|
[StringLength(11)]
|
||||||
public string Mobile { get; set; }
|
public string Mobile { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[StringLength(5)]
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
Shared/DTOs/VerificationCodeDto.cs
Normal file
15
Shared/DTOs/VerificationCodeDto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Shared.DTOs
|
||||||
|
{
|
||||||
|
public class VerificationCodeDto
|
||||||
|
{
|
||||||
|
public string prm { get; set; }
|
||||||
|
public string val { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,8 @@
|
|||||||
<div class="contact-info-area pb-90" id="contact">
|
@using Front.Pages
|
||||||
|
@using Shared.DTOs
|
||||||
|
@inject HttpClient _hc
|
||||||
|
|
||||||
|
<div class="contact-info-area pb-90" id="contact">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
</div>
|
</div>
|
||||||
@@ -27,62 +31,46 @@
|
|||||||
<div class="col-xl-7 col-lg-6">
|
<div class="col-xl-7 col-lg-6">
|
||||||
<div class="contact-form-right-warp">
|
<div class="contact-form-right-warp">
|
||||||
<div class="postbox__comment-form">
|
<div class="postbox__comment-form">
|
||||||
<form action="#" class="box">
|
<EditForm EditContext="editContext" OnValidSubmit="newTicket">
|
||||||
|
<DataAnnotationsValidator />
|
||||||
|
<div class="postbox__comment-input mb-35">
|
||||||
|
<ValidationMessage For="()=>model.FullName" />
|
||||||
|
<ValidationMessage For="()=>model.Mobile" />
|
||||||
|
<ValidationMessage For="()=>model.Title" />
|
||||||
|
<ValidationMessage For="()=>model.Text" />
|
||||||
|
</div>
|
||||||
<div class="row gx-20">
|
<div class="row gx-20">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="postbox__comment-input mb-30">
|
<div class="postbox__comment-input mb-30">
|
||||||
<input type="text" class="inputText" required="">
|
<InputText @bind-Value="model.FullName" id="FullName" type="text" class="inputText" required="" />
|
||||||
<span class="floating-label">نام شما</span>
|
<span class="floating-label">نام شما</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="postbox__comment-input mb-30">
|
<div class="postbox__comment-input mb-35">
|
||||||
<input type="text" class="inputText" required="">
|
<InputText @bind-Value="model.Mobile" id="Mobile" type="text" class="inputText" required=""/>
|
||||||
<span class="floating-label">ایمیل شما</span>
|
<span class="floating-label">موبایل</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="postbox__comment-input mb-35">
|
<div class="postbox__comment-input mb-35">
|
||||||
<input type="text" class="inputText" required="">
|
<InputText @bind-Value="model.Title" id="Title" type="text" class="inputText" required=""/>
|
||||||
<span class="floating-label">شماره تماس</span>
|
<span class="floating-label">عنوان</span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="postbox__select mb-30">
|
|
||||||
<select style="display: none;">
|
|
||||||
<option>موضوع</option>
|
|
||||||
<option>موضوع 1</option>
|
|
||||||
<option>موضوع 2</option>
|
|
||||||
<option>موضوع 3</option>
|
|
||||||
<option>موضوع 4</option>
|
|
||||||
<option>موضوع 5</option>
|
|
||||||
</select>
|
|
||||||
<div class="nice-select" tabindex="0">
|
|
||||||
<span class="current">موضوع</span>
|
|
||||||
<ul class="list">
|
|
||||||
<li data-value="موضوع" class="option selected">موضوع</li>
|
|
||||||
<li data-value="موضوع 1" class="option">موضوع 1</li>
|
|
||||||
<li data-value="موضوع 2" class="option">موضوع 2</li>
|
|
||||||
<li data-value="موضوع 3" class="option">موضوع 3</li>
|
|
||||||
<li data-value="موضوع 4" class="option">موضوع 4</li>
|
|
||||||
<li data-value="موضوع 5" class="option">موضوع 5</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xxl-12">
|
<div class="col-xxl-12">
|
||||||
<div class="postbox__comment-input mb-30">
|
<div class="postbox__comment-input mb-30">
|
||||||
<textarea class="textareaText" required=""></textarea>
|
<InputText @bind-Value="model.Text" id="Text" class="textareaText" required=""></InputText>
|
||||||
<span class="floating-label-2">پیام شما ...</span>
|
<span class="floating-label-2">پیام شما ...</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xxl-12">
|
<div class="col-xxl-12">
|
||||||
<div class="postbox__btn-box">
|
<div class="postbox__btn-box">
|
||||||
<button class="submit-btn w-100">ارسال پیام</button>
|
<button type="submit" class="submit-btn w-100">ارسال پیام</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</EditForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,5 +79,46 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
string type = "NewTicketNoAuthentication";
|
||||||
|
private EditContext? editContext;
|
||||||
|
[SupplyParameterFromForm]
|
||||||
|
private CTicketNoAuthenticationDto? model { get; set; } = new CTicketNoAuthenticationDto();
|
||||||
|
|
||||||
|
private ValidationMessageStore? messageStore;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
// modelTaxTools ??= new();
|
||||||
|
// editContext = new(modelTaxTools);
|
||||||
|
// editContext.OnValidationRequested += HandleValidationRequested;
|
||||||
|
// messageStore = new(editContext);
|
||||||
|
|
||||||
|
editContext = new EditContext(model);
|
||||||
|
messageStore = new(editContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@functions{
|
||||||
|
private async Task newTicket(){
|
||||||
|
|
||||||
|
// var request = await _hc.PostAsJsonAsync("Ticket/NewTicketNoAuthentication", model);
|
||||||
|
// if (request.IsSuccessStatusCode)
|
||||||
|
// {
|
||||||
|
// messageStore?.Clear();
|
||||||
|
// var res = await request.Content.ReadFromJsonAsync<VerificationCodeDto>();
|
||||||
|
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<List<string>>();
|
||||||
|
// messageStore?.Add(() => model.Mobile, error);
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,13 @@
|
|||||||
<h3>Verification</h3>
|
@using Shared.DTOs
|
||||||
|
@page "/Verification/{model}"
|
||||||
|
<h3>Verification</h3>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public VerificationCodeDto? model { get; set; }
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var dfsf = model;
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user