SessionController.cs
Home
/
Application /
Controllers /
SessionController.cs
using CodeEditorApi.Helpers;
using Microsoft.AspNetCore.Mvc;
namespace CodeEditorApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class SessionController : ControllerBase
{
private readonly ILogger<SessionController> _logger;
public SessionController(ILogger<SessionController> logger)
{
_logger = logger;
}
[HttpPost("create")]
public Session CreateSession([FromBody] Session newSession)
{
return SessionFiles.Create(newSession.Id);
}
[HttpPost("set")]
public void SetData([FromBody] SessionData data)
{
SessionFiles.Save(data);
}
[HttpGet("all")]
public IEnumerable<Session> Sessions()
{
return SessionFiles.Get();
}
[HttpGet("data/{sessionId}")]
public IEnumerable<SessionData> SessionData(Guid sessionId)
{
return SessionFiles.Get(sessionId);
}
}
}