Ejemplo n.º 1
0
        public static User RestoreUserByID(long IDUser)
        {
            try
            {
                using (MyDoctorBDEntities db = new MyDoctorBDEntities())
                {
                    var user = db.Users.Where(u => u.IDUser == IDUser).SingleOrDefault();

                    return user;
                }
            }
            catch(Exception)
            {
                return null;
            }
        }
Ejemplo n.º 2
0
        public static bool AuthenticateUser(string login, string pwd)
        {
            byte[] data = System.Text.Encoding.ASCII.GetBytes(pwd);
            data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
            String hash = System.Text.Encoding.ASCII.GetString(data);

            try
            {
                using (MyDoctorBDEntities db = new MyDoctorBDEntities())
                {
                    var user = db.Users.Where(x => x.Login == login && x.Password == hash).SingleOrDefault();
                    if (user == null)
                        return false;

                    MyDoctor.Repo.RepoCookies.UserCookieAuthentication(user);
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }