56 lines
2.1 KiB
C#
56 lines
2.1 KiB
C#
using System;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Interfaces;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Client.CoreApi;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Adminisztracio.ApiControllers
|
|
{
|
|
[ApiRoleClaimsAuthorize(true)]
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.IsFeltarGondviselo.ClaimValue)]
|
|
public class FeltarGondviseloApiController : ApiController
|
|
{
|
|
private readonly IFileServiceHelper fileServiceHelper;
|
|
private readonly ICoreApiClient coreApiClient;
|
|
|
|
public FeltarGondviseloApiController(IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient)
|
|
{
|
|
this.fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
|
this.coreApiClient = coreApiClient ?? throw new ArgumentNullException(nameof(coreApiClient));
|
|
}
|
|
|
|
[HttpGet]
|
|
public bool IsEszkozIgenyelheto()
|
|
{
|
|
return new FeltarGondviseloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).IsEszkozIgenyelheto(ClaimData.FelhasznaloId);
|
|
}
|
|
|
|
[HttpPost]
|
|
public HttpResponseMessage EszkozIgenyles(FeltarGondviseloCo feltarGondviselo)
|
|
{
|
|
try
|
|
{
|
|
if (feltarGondviselo.AdatvedelmiTajekoztatoElfogadasa && feltarGondviselo.AltalanosSzerzodesiFeltetelekElfogadasa && IsEszkozIgenyelheto())
|
|
{
|
|
new FeltarGondviseloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).EszkozIgenyles(ClaimData.FelhasznaloId, ClaimData.GondviseloId.Value);
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.BadRequest);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
}
|
|
}
|
|
}
|