demo_trade/Domain/LoginUseCase.cs
2024-10-04 15:41:04 +03:00

30 lines
943 B
C#

using demo_trade.Data.RemoteData.Entity;
using demo_trade.Data.Repository;
using demo_trade.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
namespace demo_trade.Domain
{
public class LoginUseCase
{
private ILoginRepository _loginRepository;
public LoginUseCase(ILoginRepository loginRepository) {
_loginRepository = loginRepository;
}
public User AutorizationByLoginAndPassword(UserLogin userLogin)
{
User? user = _loginRepository.GetUserByLogin(userLogin.Login);
if (user == null) throw new AuthenticationException("Пользователь не найден");
if (user.Userpassword != userLogin.Password) throw new AuthenticationException("Пароли не совпадают");
return user;
}
}
}