Added a new API for Panels so they can sync with a dedicated api. Removed ability to save progress with Panels.
This commit is contained in:
parent
0cf760ecd3
commit
c62e48f06a
3 changed files with 91 additions and 8 deletions
33
API/Controllers/PanelsController.cs
Normal file
33
API/Controllers/PanelsController.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.DTOs;
|
||||
using API.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// For the Panels app explicitly
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public class PanelsController : BaseApiController
|
||||
{
|
||||
private readonly IReaderService _readerService;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public PanelsController(IReaderService readerService, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_readerService = readerService;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
[HttpPost("save-progress")]
|
||||
public async Task<ActionResult> SaveProgress(ProgressDto dto, [FromQuery] string apiKey)
|
||||
{
|
||||
if (string.IsNullOrEmpty(apiKey)) return Unauthorized("ApiKey is required");
|
||||
var userId = await _unitOfWork.UserRepository.GetUserIdByApiKeyAsync(apiKey);
|
||||
await _readerService.SaveReadingProgress(dto, userId);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue