Merge pull request 'SES-130 Endpoint Pancerzy' (#54) from SES-130 into dev

Reviewed-on: #54
This commit is contained in:
Łukasz Góreczny 2021-01-09 14:11:09 +01:00
commit ff83237c95
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Extensions.EitherType;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ApiResponses;
using SessionCompanion.ViewModels.ArmorViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SessionCompanion.Controllers
{
[Route("api/armor")]
[ApiController]
public class ArmorController : Controller
{
private readonly IArmorService _service;
public ArmorController(IArmorService service) => _service = service;
/// <summary>
/// Metoda zwraca wszystkie dostępne pancerze
/// </summary>
/// <returns>Lista wszystkich pancerzy w bazie danych</returns>
[HttpGet("getAllArmor")]
public async Task<Either<List<ArmorViewModel>, ErrorResponse>> GetArmors()
{
try
{
var armors = _service.Get().ToList();
return armors;
}
catch (Exception e)
{
return new ErrorResponse()
{
StatusCode = 204,
Message = e.Message
};
}
}
}
}

View File

@ -4,6 +4,12 @@
<name>SessionCompanion</name>
</assembly>
<members>
<member name="M:SessionCompanion.Controllers.ArmorController.GetArmors">
<summary>
Metoda zwraca wszystkie dostępne pancerze
</summary>
<returns>Lista wszystkich pancerzy w bazie danych</returns>
</member>
<member name="M:SessionCompanion.Controllers.CharacterController.Get(System.Int32)">
<summary>
Metoda zwraca postać ze wskazanym identyfikatorem