using System.Threading.Tasks; using API.Extensions; using API.Interfaces; using Microsoft.AspNetCore.Mvc; namespace API.Controllers { public class ImageController : BaseApiController { private readonly IUnitOfWork _unitOfWork; public ImageController(IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; } [HttpGet("chapter-cover")] public async Task GetChapterCoverImage(int chapterId) { var content = await _unitOfWork.VolumeRepository.GetChapterCoverImageAsync(chapterId); if (content == null) return BadRequest("No cover image"); const string format = "jpeg"; Response.AddCacheHeader(content); return File(content, "image/" + format, $"chapterId"); } [HttpGet("volume-cover")] public async Task GetVolumeCoverImage(int volumeId) { var content = await _unitOfWork.SeriesRepository.GetVolumeCoverImageAsync(volumeId); if (content == null) return BadRequest("No cover image"); const string format = "jpeg"; Response.AddCacheHeader(content); return File(content, "image/" + format, $"volumeId"); } [HttpGet("series-cover")] public async Task GetSeriesCoverImage(int seriesId) { var content = await _unitOfWork.SeriesRepository.GetSeriesCoverImageAsync(seriesId); if (content == null) return BadRequest("No cover image"); const string format = "jpeg"; Response.AddCacheHeader(content); return File(content, "image/" + format, $"seriesId"); } } }