public string GetApplicationUsername(Guid userId) { ApplicationUsers appUser = new ApplicationUsers(); var query = Sql.Builder .Append("SELECT [ProvisioningRecords].[dbo].[Users].[UserName]") .Append("FROM [ProvisioningRecords].[dbo].[Users]") .Append("WHERE [ProvisioningRecords].[dbo].[Users].[UserId] = '" + userId.ToString() + "'"); appUser = _database.FirstOrDefault<ApplicationUsers>(query); return appUser.UserName; }
public ApplicationUsers GetApplicationUser(string username) { ApplicationUsers appUser = new ApplicationUsers(); var query = Sql.Builder .Append("SELECT [ProvisioningRecords].[dbo].[Users].[UserName], [ProvisioningRecords].[dbo].[Roles].[RoleName], [ProvisioningRecords].[dbo].[Users].[LastActivityDate]") .Append("FROM [ProvisioningRecords].[dbo].[Users]") .Append("LEFT OUTER JOIN [ProvisioningRecords].[dbo].[UsersInRoles]") .Append("ON [ProvisioningRecords].[dbo].[Users].[UserId] = [ProvisioningRecords].[dbo].[UsersInRoles].[UserId]") .Append("LEFT OUTER JOIN [ProvisioningRecords].[dbo].[Roles]") .Append("ON [ProvisioningRecords].[dbo].[UsersInRoles].[RoleId] = [ProvisioningRecords].[dbo].[Roles].[RoleId]") .Append("WHERE [ProvisioningRecords].[dbo].[Users].[UserName] = '" + username + "'"); appUser = _database.FirstOrDefault<ApplicationUsers>(query); return appUser; }