using Microsoft.AspNetCore.Mvc; using SchoolAgainStudyContracts.BindingModel; using SchoolAgainStudyContracts.BusinessLogicContracts; using SchoolAgainStudyContracts.SearchModel; using SchoolAgainStudyContracts.ViewModel; namespace StudentRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class StudentController : Controller { private readonly ILogger _logger; private readonly IStudentLogic _logic; public StudentController(ILogger logger, IStudentLogic studentLogic) { _logger = logger; _logic = studentLogic; } [HttpGet] public StudentViewModel? Login(string login, string password) { try { return _logic.ReadElement(new StudentSearchModel { Login = login, Password = password }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка входа в систему"); throw; } } [HttpPost] public void Register(StudentBindingModel model) { try { _logic.Create(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка регистрации"); throw; } } [HttpPost] public void UpdateData(StudentBindingModel model) { try { _logic.Update(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка обновления данных"); throw; } } } }