blob: 27905a229d0b483f1eee0fa39379939cfcee3f11 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using IOL.BookmarkThing.Server.Api.V1.Entries.Dtos;
namespace IOL.BookmarkThing.Server.Api.V1.Entries;
public class GetEntriesRoute : RouteBaseV1Sync.WithoutRequest.WithActionResult<List<EntryDto>>
{
private readonly AppDbContext _context;
public GetEntriesRoute(AppDbContext context) {
_context = context;
}
/// <summary>
/// Get all entries
/// </summary>
[ApiVersion(ApiSpecV1.VERSION_STRING)]
[HttpGet("~/v{version:apiVersion}/entries")]
public override ActionResult<List<EntryDto>> Handle() {
if (IsApiCall() && !HasApiPermission(Constants.TOKEN_ALLOW_READ)) {
return StatusCode(403, "Your token does not permit access to this resource");
}
return Ok(_context.Entries.Where(c => c.UserId == LoggedInUser.Id).Select(c => new EntryDto(c)));
}
}
|