102 lines
6.1 KiB
C#
102 lines
6.1 KiB
C#
using System;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Kreta.BusinessLogic.Interfaces;
|
|
using Kreta.Client.CoreApi;
|
|
using Kreta.Naplo.BusinessLogic.V3.HaziFeladat;
|
|
using Kreta.Naplo.Domain.V3.Enum;
|
|
using Kreta.Naplo.Dto.V3.Exception;
|
|
using Kreta.Naplo.Dto.V3.HaziFeladat;
|
|
using Kreta.Naplo.WebApi.FilterAttributes;
|
|
using Kreta.Naplo.WebApi.V3.Common.Logic;
|
|
using Kreta.Naplo.WebApi.V3.Documentation;
|
|
using Swashbuckle.Examples;
|
|
using Swashbuckle.Swagger.Annotations;
|
|
|
|
namespace Kreta.Naplo.WebApi.V3.Controllers
|
|
{
|
|
[ApiKeyAuthorization]
|
|
[IdpAuthorize(FelhasznaloSzerepkor.Tanar)]
|
|
[RoutePrefix(Constants.RoutePrefix)]
|
|
[SwaggerResponse(HttpStatusCode.NotFound, DescriptionLookUp.NemLetezoEntitasResponseLeiras, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.NotFound, typeof(NemLetezoEntitasExample))]
|
|
[SwaggerResponse(HttpStatusCode.InternalServerError, DescriptionLookUp.IsmeretlenHibaTortentResponseLeiras, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.InternalServerError, typeof(IsmeretlenHibaExample))]
|
|
[SwaggerResponse(HttpStatusCode.Unauthorized, DescriptionLookUp.JogosulatlanTokenLejartResponseLeiras, typeof(string))]
|
|
[SwaggerResponseExample(HttpStatusCode.Unauthorized, typeof(LejartTokenExample))]
|
|
[SwaggerResponse(HttpStatusCode.Forbidden, DescriptionLookUp.HozzaferesMegtagadvaResponseLeiras, typeof(string))]
|
|
[SwaggerResponseExample(HttpStatusCode.Forbidden, typeof(PermissionDeniedExample))]
|
|
[SwaggerResponse(HttpStatusCode.RequestTimeout, DescriptionLookUp.KeresTullepteMaxFutasiIdot, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.RequestTimeout, typeof(TimeOutExample))]
|
|
[SwaggerResponse(HttpStatusCode.Conflict, DescriptionLookUp.TanevetValtottAzIntezmeny, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.Conflict, typeof(IntezmenyMarTanevetValtottExample))]
|
|
public class HaziFeladatController : ApiController
|
|
{
|
|
private readonly IFileServiceHelper _fileServiceHelper;
|
|
|
|
private readonly ICoreApiClient _coreApiClient;
|
|
|
|
public HaziFeladatController(IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient)
|
|
{
|
|
_fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
|
_coreApiClient = coreApiClient ?? throw new ArgumentNullException(nameof(coreApiClient));
|
|
}
|
|
|
|
[HttpGet, Route("HaziFeladat/{id}")]
|
|
[SwaggerResponse(HttpStatusCode.OK, DescriptionLookUp.ListaUidVagyUidsFilterResponseLeiras, typeof(HaziFeladatResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.OK, typeof(DummyExampleProviderWithDependencyInjection<HaziFeladatController, HaziFeladatResponseDto>))]
|
|
public HaziFeladatResponseDto GetHaziFeladat(int id)
|
|
{
|
|
return ((HaziFeladatFacade)Activator.CreateInstance(typeof(HaziFeladatFacade), FelhasznaloLogic.GetFelhasznalo())).GetHaziFeladat(id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Házi feladat rögzítése
|
|
/// </summary>
|
|
[HttpPost, Route("HaziFeladat")]
|
|
[SwaggerResponse(HttpStatusCode.NotFound, DescriptionLookUp.NemLetezoEntitasResponseLeiras + DescriptionLookUp.HaziFeladatRogziteseSikertelenAzOraMarNemLetezikAKivalasztottNapon, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.NotFound, typeof(NemLetezoEntitasExample))]
|
|
[SwaggerResponse(HttpStatusCode.OK, DescriptionLookUp.HaziFeladatMenteseSikeres, typeof(int))]
|
|
public int SaveHaziFeladat(HaziFeladatCreateRequestDto request)
|
|
{
|
|
return ((HaziFeladatFacade)Activator.CreateInstance(typeof(HaziFeladatFacade), FelhasznaloLogic.GetFelhasznalo(), _fileServiceHelper, _coreApiClient)).SaveHaziFeladat(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Házi feladat módosítása
|
|
/// </summary>
|
|
[HttpPut, Route("HaziFeladat/{id}")]
|
|
[SwaggerResponse(HttpStatusCode.NotFound, DescriptionLookUp.NemLetezoEntitasResponseLeiras + DescriptionLookUp.HaziFeladatModositasaSikertelenAHaziFeladatNemLetezik, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.NotFound, typeof(NemLetezoEntitasExample))]
|
|
[SwaggerResponse(HttpStatusCode.OK, DescriptionLookUp.HaziFeladatMenteseSikeres, typeof(void))]
|
|
public void UpdateHaziFeladat([FromUri] int id, [FromBody] HaziFeladatUpdateRequestDto request)
|
|
{
|
|
((HaziFeladatFacade)Activator.CreateInstance(typeof(HaziFeladatFacade), FelhasznaloLogic.GetFelhasznalo(), _fileServiceHelper, _coreApiClient)).UpdateHaziFeladat(id, request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Házi feladat törlése
|
|
/// </summary>
|
|
[HttpDelete, Route("HaziFeladat/{id}")]
|
|
[SwaggerResponse(HttpStatusCode.NotFound, DescriptionLookUp.NemLetezoEntitasResponseLeiras + DescriptionLookUp.HaziFeladatTorleseSikertelenAHaziFeladatNemLetezik, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.NotFound, typeof(NemLetezoEntitasExample))]
|
|
[SwaggerResponse(HttpStatusCode.OK, DescriptionLookUp.HaziFeladatTorleseSikeres, typeof(void))]
|
|
public void DeleteHaziFeladat([FromUri] int id)
|
|
{
|
|
((HaziFeladatFacade)Activator.CreateInstance(typeof(HaziFeladatFacade), FelhasznaloLogic.GetFelhasznalo(), _coreApiClient)).DeleteHaziFeladat(id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Házi feladat csatolmány törlése
|
|
/// </summary>
|
|
[HttpDelete, Route("HaziFeladat/Csatolmany/{id}")]
|
|
[SwaggerResponse(HttpStatusCode.NotFound, DescriptionLookUp.NemLetezoEntitasResponseLeiras, typeof(NaploExceptionResponseDto))]
|
|
[SwaggerResponseExample(HttpStatusCode.NotFound, typeof(NemLetezoEntitasExample))]
|
|
[SwaggerResponse(HttpStatusCode.NoContent, DescriptionLookUp.HaziFeladatCsatolmanyTorlesSikeres, typeof(void))]
|
|
public void HaziFeladatCsatolmanyTorles(int id)
|
|
{
|
|
((HaziFeladatFacade)Activator.CreateInstance(typeof(HaziFeladatFacade), FelhasznaloLogic.GetFelhasznalo(), _fileServiceHelper)).HaziFeladatCsatolmanyTorles(id);
|
|
}
|
|
}
|
|
}
|