internal void CreateMeasurement(Activity activity, string MeasurementResult, string insertedDateOfMeasurement) { DateTime dateOfMeasurement = Convert.ToDateTime(insertedDateOfMeasurement); Double result = Double.Parse(MeasurementResult); Measurement newMeasurement = new Measurement(activity.Id, result, dateOfMeasurement); dataQualityAssurance.AddNewMeasurement(activity, newMeasurement); }
public string AddNewMeasurement(Activity activity, Measurement newMeasurement) { try { SqlCommand sqlcmd = new SqlCommand("CreateNewMeasurement", conn); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add(new SqlParameter("@fk_ActivityID", activity.Id)); sqlcmd.Parameters.Add(new SqlParameter("@Result", newMeasurement.Result)); sqlcmd.Parameters.Add(new SqlParameter("@DateOfMeasurement", newMeasurement.DateOfMeasurement)); conn.Open(); sqlcmd.ExecuteNonQuery(); conn.Close(); return "Activity created!"; } catch (SqlException e) { return e.Message; } finally { conn.Close(); } }