public LabelingComment Get(int ProcessOrderNr) { //create empty labelingComment object LabelingComment a = null; //query database using (SqlCommand cmd = new SqlCommand(GET_ONE, SQLConnectionSingleton.Instance.DbConnection)) { //binding of relevent DB parameters cmd.Parameters.AddWithValue("@ProcessOrderNr", ProcessOrderNr); //Reader to handle the result SqlDataReader reader = cmd.ExecuteReader(); //while there's a result while (reader.Read()) { a = new LabelingComment() { ProcessOrderNR = reader.GetInt32(0), WorkerID = reader.GetInt32(1), Comment = reader.GetString(2).ToString() }; } //the IO stream of data, coming from database is closed reader.Close(); } //Return the activity from database, or "null" if no user with LabelingComment = ProcessOrdreNr return(a); }
public bool Post(LabelingComment labelingComment) { SqlCommand cmd = new SqlCommand(INSERT, SQLConnectionSingleton.Instance.DbConnection); cmd.Parameters.AddWithValue("@ProcessOrderNr", labelingComment.ProcessOrderNR); cmd.Parameters.AddWithValue("@WorkerID", labelingComment.WorkerID); cmd.Parameters.AddWithValue("@Comment", labelingComment.Comment); int rowsAffected = cmd.ExecuteNonQuery(); return(rowsAffected == 1); }
public bool Put(LabelingComment labelingComment) { SqlCommand cmd = new SqlCommand(UPDATE, SQLConnectionSingleton.Instance.DbConnection); cmd.Parameters.AddWithValue("@ProcessOrderNr", labelingComment.ProcessOrderNR); cmd.Parameters.AddWithValue("@WorkerID", labelingComment.WorkerID); cmd.Parameters.AddWithValue("@Comment", labelingComment.Comment); int noOfRows = cmd.ExecuteNonQuery(); return(noOfRows == 1); }
public static LabelingComment LoadComment(int ProcessOrderNummer) { LabelingComment comment = new LabelingComment(); using (HttpClient client = new HttpClient()) { Task <string> response = client.GetStringAsync("http://localhost:54926/api/LabelingComment/" + ProcessOrderNummer); comment = JsonConvert.DeserializeObject <LabelingComment>(response.Result); } return(comment); }
// PUT: api/LabelingComment/5 public bool Put([FromBody] LabelingComment value) { return(labelingCommentManager.Put(value)); }