mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-18 03:13:46 +00:00
feat: 2e save character initial implementation WIP
2e is hidden behind url navigation hiding, so hoping that nobody found it yet. Note: DB migration make this commit a bit risky!
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kemkas.Web.Db.Models;
|
||||
using Kemkas.Web.Services.SecondEdition.Character;
|
||||
using Kemkas.Web.Services.Shared;
|
||||
using Kemkas.Web.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Kemkas.Web.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class Character2EController(
|
||||
ICharacter2EDtoToDbModelService dtoToDbModelService,
|
||||
ICharacterPersistenceService persistenceService
|
||||
) : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<Guid>> StoreNewCharacter([FromBody] Character2eDto dto, [FromQuery]bool isPublic = true)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
// var errors = validationService.Validate(dto);
|
||||
// if (errors != null)
|
||||
// {
|
||||
// return BadRequest(errors);
|
||||
// }
|
||||
|
||||
V2Karakter model;
|
||||
try
|
||||
{
|
||||
model = dtoToDbModelService.Convert(dto);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
var id = await persistenceService.StoreNewCharacter2E(model, isPublic);
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user