✨ Post with polls
This commit is contained in:
@@ -14,13 +14,13 @@ namespace DysonNetwork.Sphere.Poll;
|
||||
public class PollController(AppDatabase db, PollService polls, PublisherService pub) : ControllerBase
|
||||
{
|
||||
[HttpGet("{id:guid}")]
|
||||
public async Task<ActionResult<PollWithAnswer>> GetPoll(Guid id)
|
||||
public async Task<ActionResult<PollWithStats>> GetPoll(Guid id)
|
||||
{
|
||||
var poll = await db.Polls
|
||||
.Include(p => p.Questions)
|
||||
.FirstOrDefaultAsync(p => p.Id == id);
|
||||
if (poll is null) return NotFound("Poll not found");
|
||||
var pollWithAnswer = PollWithAnswer.FromPoll(poll);
|
||||
var pollWithAnswer = PollWithStats.FromPoll(poll);
|
||||
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Ok(pollWithAnswer);
|
||||
|
||||
|
Reference in New Issue
Block a user