Diplom_B/User.cs

45 lines
837 B
C#
Raw Normal View History

2021-07-15 12:21:22 +05:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Diplom_B.DB;
namespace Diplom_B
{
public class User
{
private string user = "";
private string password = "";
public User(string user, string password)
{
this.user = user;
this.password = password;
}
public bool CheckUser()
{
var res = false;
using (var db = new MainDB())
{
var usr = (from u in db.Users
where u.Name == user
select u).ToArray();
res = usr.Length == 1;
}
return res;
}
public bool Login()
{
var res = false;
using (var db = new MainDB())
{
var usr = (from u in db.Users
where u.Name == user && u.Pass == password
select u).ToArray();
res = usr.Length == 1;
}
return res;
}
}
}