using Back.Services; using Back.Validations; 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; private readonly MobileValidation _mobilevalidation; public BaseController(ServBase sBase, MobileValidation mobilevalidation) { _sBase = sBase; _mobilevalidation = mobilevalidation; } [HttpGet("Pricing")] public async Task>> Pricing() => Ok(await _sBase.GetBasePrice()); [HttpGet("DateTimeServer")] public async Task> DateTimeServer() => Ok(DateTime.Now); [HttpGet("LastBlog")] public async Task>> LastBlog(int PageIndex,int PageSize) => Ok(await _sBase.GetBlog(PageIndex,PageSize)); [HttpGet("GetBlogByID/{ID}")] public async Task> GetBlogByID(int ID) { var result = await _sBase.GetBlogByID(ID); if (result == null) return NotFound(); return Ok(result); } [HttpGet("LastQuestion")] public async Task>> LastQuestion(int PageIndex, int PageSize) => Ok(await _sBase.GetQuestion(PageIndex, PageSize)); [HttpPost("CreateCsrAndPrivateKey")] public async Task> CreateCsrAndPrivateKey(CsrPrivateKeyDto model) { var resultValidationmodel = await _mobilevalidation.ValidateAsync(model.Mobile); if (!resultValidationmodel.IsValid) return BadRequest(resultValidationmodel.Errors); return Ok(await _sBase.CreateCsrAndPrivateKey(model)); } [HttpPost("ReadPublicKeyFromCER")] public async Task> ReadPublicKeyFromCER(string modelfromBase64) => Ok(await _sBase.ReadPublicKeyFromCER(modelfromBase64)); } }