Skip to content

Changes to API Controllers #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DDDToolkit.API/AggregateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ protected AggregateController(IApplicationService<T, TId> applicationService)

[HttpGet]
[Route("{id}")]
public virtual Task<T> GetById(TId id) => _readableAggregateController.GetById(id);
public virtual Task<IActionResult> GetById(TId id) => _readableAggregateController.GetById(id);

[HttpGet]
public virtual Task<IReadOnlyCollection<T>> GetAll() => _readableAggregateController.GetAll();
public virtual Task<IActionResult> GetAll() => _readableAggregateController.GetAll();

[HttpPost]
public virtual Task<IActionResult> Create([FromBody] T aggregate) => _writableAggregateController.Create(aggregate);
Expand Down
5 changes: 3 additions & 2 deletions src/DDDToolkit.API/IReadableAggregateController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using DDDToolkit.Core.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace DDDToolkit.API
{
public interface IReadableAggregateController<T, TId> where T : class, IAggregateRoot<TId>
{
Task<IReadOnlyCollection<T>> GetAll();
Task<T> GetById(TId id);
Task<IActionResult> GetAll();
Task<IActionResult> GetById(TId id);
}
}
8 changes: 4 additions & 4 deletions src/DDDToolkit.API/ReadableAggregateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ protected ReadableAggregateController(IReadableApplicationService<T, TId> applic

[HttpGet]
[Route("{id}")]
public async Task<T> GetById(TId id)
public async Task<IActionResult> GetById(TId id)
{
return await _applicationService.GetById(id);
return Ok(await _applicationService.GetById(id));
}

[HttpGet]
public async Task<IReadOnlyCollection<T>> GetAll()
public async Task<IActionResult> GetAll()
{
return await _applicationService.GetAll();
return Ok(await _applicationService.GetAll());
}
}
}