Introduce dtos
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using GerbilManager.Models;
|
||||
using GerbilManager.Repositories;
|
||||
using GerbilManager.Dtos;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GerbilManager.Converter;
|
||||
|
||||
namespace GerbilManager.Controllers
|
||||
{
|
||||
@@ -17,17 +20,17 @@ namespace GerbilManager.Controllers
|
||||
|
||||
//GET /gerbils
|
||||
[HttpGet]
|
||||
public IEnumerable<Gerbil> GetGerbils()
|
||||
public IEnumerable<GerbilDto> GetGerbils()
|
||||
{
|
||||
var items = repository.GetGerbils();
|
||||
var items = repository.GetGerbils().Select( gerbil => gerbil.AsDto());
|
||||
return items;
|
||||
}
|
||||
|
||||
//GET /gerbils
|
||||
[HttpGet("{id}")]
|
||||
public ActionResult<Gerbil> GetGerbil(Guid id)
|
||||
public ActionResult<GerbilDto> GetGerbil(Guid id)
|
||||
{
|
||||
var item = repository.GetGerbil(id);
|
||||
var item = repository.GetGerbil(id).AsDto();
|
||||
|
||||
if(item is null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user