SES-131 Add Error Reponse

This commit is contained in:
Karol Górzyński 2021-01-08 17:47:43 +01:00
parent 28a27472a8
commit 6c3e23a1ea

View File

@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Extensions.EitherType;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ApiResponses;
using SessionCompanion.ViewModels.OtherEquipmentViewModels;
using System;
using System.Collections.Generic;
@ -20,9 +22,21 @@ namespace SessionCompanion.Controllers
/// </summary>
/// <returns>Lista wszystkich innych przedmiotów w bazie danych</returns>
[HttpGet("getAllOtherEquipment")]
public async Task<List<OtherEquipmentViewModel>> GetOtherEquipment()
public async Task<Either<List<OtherEquipmentViewModel>, ErrorResponse>> GetOtherEquipment()
{
return _service.Get().ToList();
try
{
var otherEq = _service.Get().ToList();
return otherEq;
}
catch (Exception e)
{
return new ErrorResponse()
{
StatusCode = 204,
Message = e.Message
};
}
}
}
}