public int AuthenticateUser() { mcpnetEntities_dev db = new mcpnetEntities_dev(); ObjectParameter output = new ObjectParameter("UserID", typeof(Int32)); ClassicEncryption enc = new ClassicEncryption(); db.uspAuthenticateUser(this.UserName, enc.EncryptForLogin(this.Password), output); this.UserID = (int)output.Value; return this.UserID; }
public static bool UserOwnsCar(int userID, int carID) { try { string strQuery = "SELECT COUNT(*) AS Result FROM Cars WHERE UserID = @UserID AND CarID = @CarID"; var db = new mcpnetEntities_dev(); var parameters = new SqlParameter[2]; parameters[0] = new SqlParameter("UserID", userID); parameters[1] = new SqlParameter("CarID", carID); var result = db.Database.SqlQuery<int>(strQuery, parameters).Single(); db.Dispose(); if (result == 1) return true; else return false; } catch (Exception ex) { } return false; }