base logic #5

Merged
mfnefd merged 25 commits from registration into main 2024-06-10 12:27:55 +04:00
Showing only changes of commit 2533ba90c0 - Show all commits

View File

@ -21,11 +21,11 @@ namespace RestAPI.Controllers
} }
[HttpPost] [HttpPost]
public IResult Login([FromBody] UserBindingModel model) public IResult Login(string email, string password)
{ {
try try
{ {
var res = _userLogic.Login(model); var res = _userLogic.Login(email, password);
return Results.Ok(res); return Results.Ok(res);
} }
catch (ElementNotFoundException ex) catch (ElementNotFoundException ex)
@ -50,17 +50,19 @@ namespace RestAPI.Controllers
{ {
try try
{ {
var res = _userLogic.Login(model); var res = _userLogic.Create(model);
return Results.Ok(res); return Results.Ok(res);
} }
catch (AccountException ex) catch (AccountException ex)
{ {
_logger.LogWarning(ex, "Wrong registration data"); _logger.LogWarning(ex, "Wrong registration data");
throw;
return Results.BadRequest(ex.Message); return Results.BadRequest(ex.Message);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error create user"); _logger.LogError(ex, "Error create user");
throw;
return Results.Problem(ex.Message); return Results.Problem(ex.Message);
} }
} }