fix: app
This commit is contained in:
@@ -20,22 +20,30 @@ public class DialogueController : ControllerBase
|
||||
[HttpGet("mission/{missionId:guid}")]
|
||||
public async Task<IActionResult> GetByMission(Guid missionId)
|
||||
{
|
||||
var d = await _dialogueService.GetDialogueByMissionIdAsync(missionId);
|
||||
return d == null ? NotFound() : Ok(d);
|
||||
var dialogue = await _dialogueService.GetDialogueByMissionIdAsync(missionId);
|
||||
if (dialogue == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Ok(dialogue);
|
||||
}
|
||||
|
||||
[HttpGet("message/{messageId:guid}")]
|
||||
public async Task<IActionResult> GetMessage(Guid messageId)
|
||||
{
|
||||
var m = await _dialogueService.GetDialogueMessageByIdAsync(messageId);
|
||||
return m == null ? NotFound() : Ok(m);
|
||||
var message = await _dialogueService.GetDialogueMessageByIdAsync(messageId);
|
||||
if (message == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Ok(message);
|
||||
}
|
||||
|
||||
[HttpGet("message/{messageId:guid}/options")]
|
||||
public async Task<IActionResult> GetOptions(Guid messageId)
|
||||
{
|
||||
var opts = await _dialogueService.GetResponseOptionsAsync(messageId);
|
||||
return Ok(opts);
|
||||
var options = await _dialogueService.GetResponseOptionsAsync(messageId);
|
||||
return Ok(options);
|
||||
}
|
||||
|
||||
public record DialogueResponseRequest(Guid ResponseOptionId, Guid PlayerId);
|
||||
@@ -44,7 +52,10 @@ public class DialogueController : ControllerBase
|
||||
public async Task<IActionResult> Respond(Guid messageId, DialogueResponseRequest req)
|
||||
{
|
||||
var next = await _dialogueService.ProcessDialogueResponseAsync(messageId, req.ResponseOptionId, req.PlayerId);
|
||||
if (next == null) return Ok(new { end = true });
|
||||
if (next == null)
|
||||
{
|
||||
return Ok(new { end = true });
|
||||
}
|
||||
return Ok(next);
|
||||
}
|
||||
|
||||
@@ -60,16 +71,16 @@ public class DialogueController : ControllerBase
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Create(CreateDialogueRequest dto)
|
||||
{
|
||||
var d = new Dialogue
|
||||
var dialogue = new Dialogue
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
MissionId = dto.MissionId,
|
||||
InitialDialogueMessageId = dto.InitialDialogueMessageId,
|
||||
InterimDialogueMessageId = dto.InterimDialogueMessageId,
|
||||
EndDialogueMessageId = dto.EndDialogueMessageId,
|
||||
Mission = null! // EF will populate if included
|
||||
Mission = null!
|
||||
};
|
||||
d = await _dialogueService.CreateDialogueAsync(d);
|
||||
return CreatedAtAction(nameof(GetByMission), new { missionId = d.MissionId }, d);
|
||||
dialogue = await _dialogueService.CreateDialogueAsync(dialogue);
|
||||
return CreatedAtAction(nameof(GetByMission), new { missionId = dialogue.MissionId }, dialogue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user