/// <summary> /// Selects person grant points by id /// </summary> /// <param name="personGrantPointsID"></param> /// <returns></returns> public PersonGrantPointsVM SelectPersonGrantPointsByPersonGrantPointsID(int personGrantPointsID) { PersonGrantPointsVM personGrantPoint = new PersonGrantPointsVM(); var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_select_person_grant_points_by_person_grant_points_id", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PersonGrantPointsID", personGrantPointsID); try { var reader = cmd.ExecuteReader(); if (reader.Read()) { personGrantPoint.PersonGrantPointsID = reader.GetInt32(0); personGrantPoint.PersonID = reader.GetInt32(1); personGrantPoint.Points = reader.GetInt32(2); personGrantPoint.FirstName = reader.GetString(3); personGrantPoint.LastName = reader.GetString(4); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(personGrantPoint); }
/// <summary> /// Selects all available person grant points /// </summary> /// <returns></returns> public List <PersonGrantPointsVM> SelectAllPersonGrantPoints() { List <PersonGrantPointsVM> personGrantPoints = new List <PersonGrantPointsVM>(); var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_select_all_person_grant_points", conn); cmd.CommandType = CommandType.StoredProcedure; try { var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var personGrantPoint = new PersonGrantPointsVM(); personGrantPoint.PersonGrantPointsID = reader.GetInt32(0); personGrantPoint.PersonID = reader.GetInt32(1); personGrantPoint.Points = reader.GetInt32(2); personGrantPoint.FirstName = reader.GetString(3); personGrantPoint.LastName = reader.GetString(4); personGrantPoints.Add(personGrantPoint); } } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(personGrantPoints); }