2024-04-13 15:03:27 +03:30
|
|
|
|
using Back.Common.Enums;
|
|
|
|
|
using Back.Data.Models;
|
2024-04-14 16:09:36 +03:30
|
|
|
|
using Back.Services;
|
|
|
|
|
using Back.Validations;
|
2024-04-13 15:03:27 +03:30
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Shared.DTOs;
|
2024-04-14 16:09:36 +03:30
|
|
|
|
using System.Security.Cryptography;
|
2024-04-13 15:03:27 +03:30
|
|
|
|
|
|
|
|
|
namespace Back.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class TicketController : ControllerBase
|
|
|
|
|
{
|
2024-04-14 16:09:36 +03:30
|
|
|
|
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;
|
|
|
|
|
}
|
2024-04-13 15:03:27 +03:30
|
|
|
|
|
|
|
|
|
[HttpPost("NewTicketNoAuthentication")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<ActionResult<int>> NewTicketNoAuthentication(CTicketNoAuthenticationDto item)
|
|
|
|
|
{
|
2024-04-14 16:09:36 +03:30
|
|
|
|
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);
|
|
|
|
|
|
2024-04-14 22:19:39 +03:30
|
|
|
|
var ID= await _servValidatinMsg.GenerateCode(new VerificationCode
|
2024-04-14 16:09:36 +03:30
|
|
|
|
{
|
|
|
|
|
prm = Ticket.ID.ToString(),
|
|
|
|
|
val = item.Mobile,
|
|
|
|
|
Type = "NewTicketNoAuthentication"
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-14 22:19:39 +03:30
|
|
|
|
return Ticket == null ? BadRequest() : Ok(ID);
|
2024-04-13 15:03:27 +03:30
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|