-
-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathCustomArticleService.cs
43 lines (40 loc) · 1.7 KB
/
CustomArticleService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Data;
using JsonApiDotNetCore.Hooks;
using JsonApiDotNetCore.Internal;
using JsonApiDotNetCore.Internal.Contracts;
using JsonApiDotNetCore.Query;
using JsonApiDotNetCore.Services;
using JsonApiDotNetCoreExample.Models;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
namespace JsonApiDotNetCoreExample.Services
{
public class CustomArticleService : DefaultResourceService<Article>
{
public CustomArticleService(ISortService sortService,
IFilterService filterService,
IResourceRepository<Article, int> repository,
IJsonApiOptions options,
IIncludeService includeService,
ISparseFieldsService sparseFieldsService,
IPageService pageService,
IResourceContextProvider provider,
IResourceHookExecutor hookExecutor = null,
ILoggerFactory loggerFactory = null)
: base(sortService, filterService, repository, options, includeService, sparseFieldsService,
pageService, provider, hookExecutor, loggerFactory)
{
}
public override async Task<Article> GetAsync(int id)
{
var newEntity = await base.GetAsync(id);
if(newEntity == null)
{
throw new JsonApiException(404, "The entity could not be found");
}
newEntity.Name = "None for you Glen Coco";
return newEntity;
}
}
}