public string updateString(string id, courseUpdate course) { if (id == null || id.Length <= 0) { return("courseIdNull"); } Guid courseId = new Guid(id); return(update(courseId, course)); }
public string update(Guid id, courseUpdate course) { try { SqlConnection con = new SqlConnection(data); SqlCommand cmd = new SqlCommand("UPDATE courseData SET " + " status = @status, " + " information = @information, " + " price = @price, " + " currency = @currency, " + " duration = @duration, " + " durationUnit = @durationUnit " + " WHERE courseId = @courseId" , con); cmd.Parameters.AddWithValue("@status", course.status); cmd.Parameters.AddWithValue("@information", course.information); cmd.Parameters.AddWithValue("@price", course.price); cmd.Parameters.AddWithValue("@currency", course.currency); cmd.Parameters.AddWithValue("@duration", course.duration); cmd.Parameters.AddWithValue("@durationUnit", course.durationUnit); cmd.Parameters.AddWithValue("@courseId", id); con.Open(); cmd.ExecuteNonQuery(); con.Close(); return("Success"); } catch (SqlException ex) { return(ex.ToString()); } catch { return("Error"); } }
public string courseUpdate(courseClass list) { courseUpdate update = new courseUpdate(); IcourseClient client = new IcourseClient(); string response = "Error"; try { update.status = list.status; update.information = list.information; update.price = list.price; update.currency = list.currency; update.duration = list.duration; update.durationUnit = list.durationUnit; response = client.updateString(list.courseId.ToString(), update); } catch { // Error } return(response); }