narsil/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs

36 lines
1018 B
C#

using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
class MsrLogin : ILogin
{
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public bool LoginUser()
{
return LoginUser(true);
}
static bool LoginUser(bool setThreadPrincipal)
{
using (var frm = new MsrLoginForm(false))
{
string userName;
frm.ShowDialog();
var authenticated = frm.UserName(out userName);
if (authenticated && setThreadPrincipal)
using (var bi = new UserBI())
Session.User = bi.Get(x => x.Name == userName);
return authenticated;
}
}
public bool LogoutUser()
{
Session.User = null;
return true;
}
}
}