SES-128 Endpoint Broni #52

Merged
s426134 merged 7 commits from SES-128 into dev 2021-01-09 14:07:07 +01:00
4 changed files with 1145 additions and 1098 deletions

4
.gitignore vendored
View File

@ -2,6 +2,10 @@
# Created by https://www.toptal.com/developers/gitignore/api/aspnetcore,node,visualstudio,visualstudiocode,vscode,windows,linux,angular # Created by https://www.toptal.com/developers/gitignore/api/aspnetcore,node,visualstudio,visualstudiocode,vscode,windows,linux,angular
# Edit at https://www.toptal.com/developers/gitignore?templates=aspnetcore,node,visualstudio,visualstudiocode,vscode,windows,linux,angular # Edit at https://www.toptal.com/developers/gitignore?templates=aspnetcore,node,visualstudio,visualstudiocode,vscode,windows,linux,angular
#Swagger
./SessionCompanion/SessionCompanion/SessionCompanion.xml
./SessionCompanion/SessionCompanion.ViewModels/SessionCompanion.ViewModels.xml
### Angular ### ### Angular ###
## Angular ## ## Angular ##
# compiled output # compiled output

View File

@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Extensions.EitherType;
using SessionCompanion.Services.Interfaces;
using System.Threading.Tasks;
using SessionCompanion.ViewModels.WeaponViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SessionCompanion.ViewModels.ApiResponses;
namespace SessionCompanion.Controllers
{
[Route("api/weapon")]
[ApiController]
public class WeaponController : Controller
{
private readonly IWeaponService _service;
public WeaponController(IWeaponService service) => _service = service;
/// <summary>
/// Metoda zwraca wszystkie dostępnasdasde bronie
/// </summary>
/// <returns>Lista wszystkich broni w bazie danych</returns>
[HttpGet("getAllWeapons")]
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
{
try
{
var weapons = _service.Get().ToList();
return weapons;
}
catch (Exception e)
{
return new ErrorResponse()
{
StatusCode = 204,
Message = e.Message
};
}
}
}
}