using Bibblan.Business.Services; using Microsoft.AspNetCore.Mvc; namespace Bibblan.Controllers { [ApiController] [Route("api/[controller]")] public class BibblanController : ControllerBase { DatabaseService _db; CalibreService _calibre; public BibblanController(DatabaseService databaseService, CalibreService calibre) { _db = databaseService; _calibre = calibre; } [HttpGet("cover")] public IActionResult GetCover(string path) { //TODO: Bör kanske inte gå direkt mot calibres filer.. var bytes = _calibre.Cover(path); return File(bytes, "image/jpeg", true); } [HttpGet("books")] public IActionResult GetBooks() { var authors = _db.GetBooks(100).ToList(); return Ok(authors); } [HttpGet("authors")] public IActionResult GetAuthors() { var authors = _db.GetAuthors(100).ToList(); return Ok(authors); } [HttpGet("books/author/{authorid}")] public IActionResult GetBooksByAuthor(int authorid) { var authors = _db.GetBooks(100, new BookFilter { Author = authorid }).ToList(); return Ok(authors); } } }