adding hidden basic asp.net core backend (#30)
Base functionality:
DB
email sending
user registration & login
storing new characters and reading them back
Notes:
Functionality is "hidden" with no links pointing to it.
Most pages are scaffolded and not reviewed at all :(
local Dev db setup is pushed to git
NO local email setup :(
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kemkas.Web.Db.Models;
|
||||
using Kemkas.Web.Services;
|
||||
using Kemkas.Web.Services.Character;
|
||||
using Kemkas.Web.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Kemkas.Web.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class CharacterController(
|
||||
ICharacterValidationService validationService,
|
||||
ICharacterDtoToDbModelService dtoToDbModelService,
|
||||
ICharacterDbModelToDtoService dbModelToDtoService,
|
||||
ICharacterPersistenceService persistenceService)
|
||||
: ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<Guid>> StoreNewCharacter([FromBody] CharacterDto dto)
|
||||
{
|
||||
var errors = validationService.Validate(dto);
|
||||
if (errors != null)
|
||||
{
|
||||
return BadRequest(errors);
|
||||
}
|
||||
|
||||
V1Karakter model;
|
||||
try
|
||||
{
|
||||
model = dtoToDbModelService.Convert(dto);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
var id = await persistenceService.StoreNewCharacter(model);
|
||||
return id;
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
public async Task<ActionResult<CharacterDto>> GetCharacterById([FromRoute] Guid id)
|
||||
{
|
||||
var entity = await persistenceService.GetCharacterById(id);
|
||||
if (entity is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return dbModelToDtoService.Convert(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Kemkas.Web.Controllers;
|
||||
|
||||
public class OidcConfigurationController : Controller
|
||||
{
|
||||
private readonly ILogger<OidcConfigurationController> _logger;
|
||||
|
||||
public OidcConfigurationController(
|
||||
IClientRequestParametersProvider clientRequestParametersProvider,
|
||||
ILogger<OidcConfigurationController> logger)
|
||||
{
|
||||
ClientRequestParametersProvider = clientRequestParametersProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
|
||||
|
||||
[HttpGet("_configuration/{clientId}")]
|
||||
public IActionResult GetClientRequestParameters([FromRoute] string clientId)
|
||||
{
|
||||
var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
|
||||
return Ok(parameters);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Kemkas.Web.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Kemkas.Web.Controllers;
|
||||
|
||||
// [Authorize]
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
|
||||
Reference in New Issue
Block a user