Automated teller machine emulation.
using System;
using System.Linq;
using SergeyDrozdovATM.Data;
namespace SergeyDrozdovATM.BLL
{
public class UserService : IUserService
{
public User GetUserByLoginAndPIN(int login, int pin)
{
User user = null;
using (var dbContext = new SergeyDrozdovATMDbContext())
{
var userInfo = dbContext.Users.FirstOrDefault(x => x.Login == login && x.PIN == pin);
if (userInfo == null)
{
throw new Exception("Wrong credentials.");
}
user = new User
{
Id = userInfo.Id,
Login = userInfo.Login,
PIN = userInfo.PIN
};
}
return user;
}
}
}