2024-11-03 19:42:19 +04:00
|
|
|
|
using EventVisitorLogic.BindingModels;
|
|
|
|
|
using EventVisitorLogic.Logic;
|
|
|
|
|
using EventVisitorLogic.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace EventVisitorRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class OrganizerController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IOrganizerLogic _logic;
|
|
|
|
|
private readonly AbstractMailWorker _mailWorker;
|
|
|
|
|
Random rnd = new Random();
|
|
|
|
|
private static readonly Random _random = new Random();
|
|
|
|
|
public OrganizerController(IOrganizerLogic logic, AbstractMailWorker mailWorker)
|
|
|
|
|
{
|
|
|
|
|
_logic = logic;
|
|
|
|
|
_mailWorker = mailWorker;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public OrganizerViewModel? Login(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _logic.ReadElement(new OrganizerBindingModel
|
|
|
|
|
{
|
|
|
|
|
Email = login,
|
|
|
|
|
Password = password
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(OrganizerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2024-11-09 23:28:41 +04:00
|
|
|
|
BadRequest(new { message = ex.Message });
|
2024-11-03 19:42:19 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateData(OrganizerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|