summaryrefslogtreecommitdiffstats
path: root/src/server/Api/V1/Entries/GetEntriesRoute.cs
blob: 6b1d87e766272b44aed133ad713915ef6611843d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)]
	[BasicAuthentication(AppConstants.TOKEN_ALLOW_READ)]
	[HttpGet("~/v{version:apiVersion}/entries")]
	public override ActionResult<List<EntryDto>> Handle() {
		return Ok(_context.Entries.Where(c => c.UserId == LoggedInUser.Id).Select(c => new EntryDto(c)));
	}
}