public List <RatingDM> Read(SqlParameter[] parameters, string statement) { using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(statement, connection)) { command.CommandType = CommandType.StoredProcedure; if (parameters != null) { command.Parameters.AddRange(parameters); } connection.Open(); SqlDataReader data = command.ExecuteReader(); List <RatingDM> ratings = new List <RatingDM>(); while (data.Read()) { RatingDM rating = new RatingDM(); rating.RateId = data["RateId"].ToString(); rating.Rating = data["Rating"].ToString(); ratings.Add(rating); } return(ratings); } } }
public void EditRatingById(RatingDM rating) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Id", rating.RateId) , new SqlParameter("@RatingName", rating.Rating) }; dataWriter.Write(parameters, "UpdateRating"); logs.LogError("Event", "An rating has been updated", "Class: RatingDAO, Method: UpdateRating"); }