kreta/KretaWeb/Areas/Adminisztracio/ApiControllers/EmailKezelesApiController.cs
2024-03-13 00:33:46 +01:00

46 lines
1.4 KiB
C#

using System;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Web.Http;
using Kreta.BusinessLogic.Helpers;
using Kreta.Core.Logic;
using Kreta.Resources;
using Kreta.Web.Helpers;
using Kreta.Web.Helpers.Error;
using Kreta.Web.Security;
namespace Kreta.Web.Areas.Adminisztracio.ApiControllers
{
[AllowAnonymous]
public class EmailKezelesApiController : ApiController
{
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public IHttpActionResult Leiratkozas([FromBody] string data)
{
try
{
Guid guid = Guid.Parse(UrlLogic.Decrypt(data, Core.Constants.EncryptionKey));
if (!new UzenetekHelper(ConnectionTypeExtensions.GetOrganizationConnectionType()).Leiratkozas(guid))
{
throw new InvalidDataException();
}
}
catch (Exception ex) when (
ex is ArgumentException ||
ex is CryptographicException ||
ex is FormatException ||
ex is InvalidDataException)
{
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.ErvenytelenAdat);
}
catch (Exception)
{
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.IsmeretlenHibaTortent);
}
return Ok();
}
}
}