parent
05d24821f7
commit
bf852cadbe
@ -0,0 +1,54 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import createClearReducer from './Creators/Reducers/createClearReducer';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
export const section = 'editions';
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
export const defaultState = {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
items: [],
|
||||
itemMap: {}
|
||||
};
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_EDITIONS = 'editions/fetchEditions';
|
||||
export const CLEAR_EDITIONS = 'editions/clearEditions';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchEditions = createThunk(FETCH_EDITIONS);
|
||||
export const clearEditions = createAction(CLEAR_EDITIONS);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
[FETCH_EDITIONS]: createFetchHandler(section, '/edition')
|
||||
});
|
||||
|
||||
//
|
||||
// Reducers
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[CLEAR_EDITIONS]: createClearReducer(section, {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
items: [],
|
||||
itemMap: {}
|
||||
})
|
||||
|
||||
}, defaultState, section);
|
@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Books;
|
||||
using Readarr.Api.V1.Books;
|
||||
using Readarr.Http;
|
||||
|
||||
namespace NzbDrone.Api.V1.Editions
|
||||
{
|
||||
[V1ApiController]
|
||||
public class EditionController : Controller
|
||||
{
|
||||
private readonly IEditionService _editionService;
|
||||
|
||||
public EditionController(IEditionService editionService)
|
||||
{
|
||||
_editionService = editionService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<EditionResource> GetEditions(int bookId)
|
||||
{
|
||||
var editions = _editionService.GetEditionsByBook(bookId);
|
||||
|
||||
return editions.ToResource();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue