Ejemplo n.º 1
0
 /// <summary>
 /// Return a userId given a user's login
 /// </summary>
 /// <param name="userLogin">The user's login info</param>
 /// <returns></returns>
 public int FindUserIdByLogin(UserLogin userLogin)
 {
     using (var conn = db.GetOpenConnection())
     {
         return conn.ExecuteScalar<int>(@"SELECT UserID FROM UserLogin 
                                             WHERE LoginProvider = @loginProvider and ProviderKey = @providerKey",
                     new
                     {
                         loginProvider = userLogin.LoginProvider,
                         providerKey = userLogin.ProviderKey
                     });
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes a login from a user in the UserLogins table
 /// </summary>
 /// <param name="user">User to have login deleted</param>
 /// <param name="login">Login to be deleted from user</param>
 /// <returns></returns>
 public void Delete(User user, UserLogin login)
 {
     using (var conn = db.GetOpenConnection())
     {
         conn.Execute(@"DELETE FROM UserLogin WHERE UserID = @userId AND LoginProvider = @loginProvider AND ProviderKey = @providerKey",
             new
             {
                 userId = user.Id,
                 loginProvider = login.LoginProvider,
                 providerKey = login.ProviderKey
             });
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Inserts a new login in the UserLogins table
 /// </summary>
 /// <param name="user">User to have new login added</param>
 /// <param name="login">Login to be added</param>
 /// <returns></returns>
 public void Insert(User user, UserLogin login)
 {
     using (var conn = db.GetOpenConnection())
     {
         conn.Execute(@"INSERT INTO UserLogin (LoginProvider, ProviderKey, UserID) 
                             VALUES (@loginProvider, @providerKey, @userId)",
                 new
                 {
                     loginProvider = login.LoginProvider,
                     providerKey = login.ProviderKey,
                     userId = user.Id
                 });
     }
 }