-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Joseph Milazzo <[email protected]>
- Loading branch information
1 parent
5934d51
commit ff79710
Showing
324 changed files
with
11,604 additions
and
4,613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Threading.Tasks; | ||
using API.Data; | ||
using API.DTOs.Theme; | ||
using API.Entities.Interfaces; | ||
using API.Extensions; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace API.Controllers; | ||
|
||
[Authorize] | ||
public class ColorScapeController : BaseApiController | ||
{ | ||
private readonly IUnitOfWork _unitOfWork; | ||
|
||
public ColorScapeController(IUnitOfWork unitOfWork) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the color scape for a series | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[HttpGet("series")] | ||
public async Task<ActionResult<ColorScapeDto>> GetColorScapeForSeries(int id) | ||
{ | ||
var entity = await _unitOfWork.SeriesRepository.GetSeriesDtoByIdAsync(id, User.GetUserId()); | ||
return GetColorSpaceDto(entity); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the color scape for a volume | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[HttpGet("volume")] | ||
public async Task<ActionResult<ColorScapeDto>> GetColorScapeForVolume(int id) | ||
{ | ||
var entity = await _unitOfWork.VolumeRepository.GetVolumeDtoAsync(id, User.GetUserId()); | ||
return GetColorSpaceDto(entity); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the color scape for a chapter | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[HttpGet("chapter")] | ||
public async Task<ActionResult<ColorScapeDto>> GetColorScapeForChapter(int id) | ||
{ | ||
var entity = await _unitOfWork.ChapterRepository.GetChapterDtoAsync(id); | ||
return GetColorSpaceDto(entity); | ||
} | ||
|
||
|
||
|
||
private ActionResult<ColorScapeDto> GetColorSpaceDto(IHasCoverImage entity) | ||
{ | ||
if (entity == null) return Ok(ColorScapeDto.Empty); | ||
return Ok(new ColorScapeDto(entity.PrimaryColor, entity.SecondaryColor)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.