2024-03-30 15:10:36 +03:30
|
|
|
|
using Back.Services;
|
2024-04-05 01:05:32 +03:30
|
|
|
|
using Back.Validations;
|
2024-03-30 15:10:36 +03:30
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Shared.DTOs;
|
|
|
|
|
|
|
|
|
|
namespace Back.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class BaseController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ServBase _sBase;
|
2024-04-05 01:05:32 +03:30
|
|
|
|
private readonly MobileValidation _mobilevalidation;
|
|
|
|
|
public BaseController(ServBase sBase, MobileValidation mobilevalidation)
|
2024-03-30 15:10:36 +03:30
|
|
|
|
{
|
|
|
|
|
_sBase = sBase;
|
2024-04-05 01:05:32 +03:30
|
|
|
|
_mobilevalidation = mobilevalidation;
|
2024-03-30 15:10:36 +03:30
|
|
|
|
}
|
2024-03-31 01:33:17 +03:30
|
|
|
|
[HttpGet("Pricing")]
|
|
|
|
|
public async Task<ActionResult<List<BasePriceDto>>> Pricing()
|
2024-03-30 15:10:36 +03:30
|
|
|
|
=> Ok(await _sBase.GetBasePrice());
|
2024-03-31 01:33:17 +03:30
|
|
|
|
[HttpGet("DateTimeServer")]
|
|
|
|
|
public async Task<ActionResult<DateTime>> DateTimeServer()
|
|
|
|
|
=> Ok(DateTime.Now);
|
2024-04-02 17:14:18 +03:30
|
|
|
|
[HttpGet("LastBlog")]
|
|
|
|
|
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex,int PageSize)
|
|
|
|
|
=> Ok(await _sBase.GetBlog(PageIndex,PageSize));
|
2024-04-03 14:36:33 +03:30
|
|
|
|
[HttpGet("GetBlogByID/{ID}")]
|
|
|
|
|
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
|
|
|
|
|
{
|
|
|
|
|
var result = await _sBase.GetBlogByID(ID);
|
|
|
|
|
if (result == null)
|
|
|
|
|
return NotFound();
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
2024-04-03 17:07:18 +03:30
|
|
|
|
[HttpGet("LastQuestion")]
|
|
|
|
|
public async Task<ActionResult<PagingDto<QuestionDto>>> LastQuestion(int PageIndex, int PageSize)
|
|
|
|
|
=> Ok(await _sBase.GetQuestion(PageIndex, PageSize));
|
2024-04-05 01:05:32 +03:30
|
|
|
|
[HttpPost("CreateCsrAndPrivateKey")]
|
|
|
|
|
public async Task<ActionResult<TaxToolsDTO>> CreateCsrAndPrivateKey(CsrPrivateKeyDto model)
|
|
|
|
|
{
|
|
|
|
|
var resultValidationmodel = await _mobilevalidation.ValidateAsync(model.Mobile);
|
|
|
|
|
if (!resultValidationmodel.IsValid)
|
2024-04-05 17:43:11 +03:30
|
|
|
|
return BadRequest(resultValidationmodel.Errors.Select(s=>s.ErrorMessage ).ToList());
|
2024-04-05 01:05:32 +03:30
|
|
|
|
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
|
|
|
|
|
}
|
|
|
|
|
[HttpPost("ReadPublicKeyFromCER")]
|
|
|
|
|
public async Task<ActionResult<PublicKeyDTO>> ReadPublicKeyFromCER(string modelfromBase64)
|
2024-04-05 21:03:40 +03:30
|
|
|
|
{
|
|
|
|
|
var result = await _sBase.ReadPublicKeyFromCER(modelfromBase64);
|
|
|
|
|
if (result.type== "error")
|
|
|
|
|
return BadRequest();
|
|
|
|
|
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
2024-04-05 01:05:32 +03:30
|
|
|
|
|
2024-03-30 15:10:36 +03:30
|
|
|
|
}
|
|
|
|
|
}
|