public bool IsAccess(string roleId, string userId, int serviceId) { IDataReader reader = null; var res = false; try { var command = Entlib.GetStoredProcCommand("sec.IsAccess"); Entlib.AddInParameter(command, "roleid", DbType.String, roleId); Entlib.AddInParameter(command, "userid", DbType.String, userId); Entlib.AddInParameter(command, "serviceid", DbType.Int32, serviceId); reader = Entlib.ExecuteReader(command); if (reader.Read()) { res = reader[0].SafeBoolean(); } return(res); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } finally { if (reader != null) { reader.Close(); reader.Dispose(); } } }
public List <IdentityRole> GetUserRolesByUsername(string username) { try { var command = Entlib.GetStoredProcCommand("sec.GetUserRolesByUsername"); Entlib.AddInParameter(command, "username", DbType.String, username); return(Entlib.ExecuteCommandAccessor(command, IdentityRoleRowMapper).ToList()); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }
public List <ApplicationUser> GetUsersByRoleId(string roleId) { try { var command = Entlib.GetStoredProcCommand("sec.GetUsersByRoleId"); Entlib.AddInParameter(command, "roleId", DbType.String, roleId); return(Entlib.ExecuteCommandAccessor(command, ApplicationUserRowMapper).ToList()); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }
public void AddTournament(Domain.Tournament tournament) { try { var command = Entlib.GetStoredProcCommand("dbo.AddTournament"); Entlib.AddInParameter(command, "GameId", DbType.Int32, tournament.GameId); Entlib.AddInParameter(command, "UserId", DbType.String, tournament.UserId); Entlib.ExecuteNonQuery(command); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw; } }
public List <Domain.Game> GetGameByUserId(string userId) { try { var command = Entlib.GetStoredProcCommand("dbo.GetGameByUserId"); Entlib.AddInParameter(command, "UserID", DbType.String, userId); var items = Entlib.ExecuteCommandAccessor(command, GameMapper).ToList(); return(items); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw; } }
public Domain.Game GetGames(int id) { try { var command = Entlib.GetStoredProcCommand("dbo.GetGamesById"); Entlib.AddInParameter(command, "Id", DbType.Int32, id); var items = Entlib.ExecuteCommandAccessor(command, GameMapper).ToList(); return(items.FirstOrDefault()); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw; } }
public ApplicationUser GetApplicationUserById(string userId) { try { var command = Entlib.GetStoredProcCommand("sec.GetApplicationUserById"); Entlib.AddInParameter(command, "UserId", DbType.String, userId); var res = Entlib.ExecuteCommandAccessor(command, ApplicationUserRowMapper); return(res != null?res.ToList().FirstOrDefault() : new ApplicationUser()); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }
public void UpdateGame(Domain.Game game) { try { var command = Entlib.GetStoredProcCommand("dbo.UpdateGame"); Entlib.AddInParameter(command, "Id", DbType.Int32, game.Id); Entlib.AddInParameter(command, "WinnerId", DbType.String, game.WinnerId); Entlib.AddInParameter(command, "Status", DbType.String, game.Status); Entlib.AddInParameter(command, "EndDate", DbType.DateTime, game.EndDate); Entlib.ExecuteNonQuery(command); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw; } }
public void UpdateAccess(ServiceAccess access) { try { var command = Entlib.GetStoredProcCommand("sec.SaveAccess"); Entlib.AddInParameter(command, "RoleId", DbType.String, access.RoleId); Entlib.AddInParameter(command, "userid", DbType.String, access.UserId); Entlib.AddInParameter(command, "allow", DbType.Boolean, access.Allow); //Entlib.AddInParameter(command, "ApplicationId", DbType.Int32, access.ApplicationId); Entlib.AddInParameter(command, "ServiceId", DbType.Int32, access.ServiceId); Entlib.AddInParameter(command, "LastUpdate", DbType.DateTime, access.LastUpdate); Entlib.ExecuteNonQuery(command); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }