CourseWork_EventVisitor/EventVisitor/EventVisitorRestApi/Controllers/OrganizerController.cs

65 lines
1.6 KiB
C#
Raw Normal View History

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)
{
throw;
}
}
[HttpPost]
public void UpdateData(OrganizerBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
throw;
}
}
}
}