SES-128 Endpoint Broni #52
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
|
||||||
|
@ -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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user