SES-130 Endpoint Pancerzy #54

Merged
s426134 merged 4 commits from SES-130 into dev 2021-01-09 14:11:10 +01:00
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>
s426135 marked this conversation as resolved
Review

Brak Error Response

Brak Error Response
[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