// POST: api/MicaApi public void Post(string svaId, [FromBody] mica_vw m) { int com = micadb.Save_SVA_Comment(svaId, m.field_sva_comment_value); int scr = micadb.Save_SVA_Script(svaId, m.field_sva_script_value); int sta = micadb.Save_SVA_Status(svaId, m.field_sva_status_value); micadb.clear_cache(); }
// Put method accepts two parameters, the Id of the updated resource which is set in URI, and the updated "Mapper” // which represents complex type deserialized in the request body // We return “HttpResponseMessage” for all possible scenarios that might happen when we execute this operation. // In case the resource is updated successfully, server should return HTTP response 200 (OK) along with the // resource created. If the resource is not modified the server should return HTTP response 304 (Not modified). public HttpResponseMessage Put(string svaId, [FromBody] mica_vw m) { int com = micadb.Save_SVA_Comment(svaId, m.field_sva_comment_value); int scr = micadb.Save_SVA_Script(svaId, m.field_sva_script_value); int sta = micadb.Save_SVA_Status(svaId, m.field_sva_status_value); if (com == 1) { return(Request.CreateResponse(HttpStatusCode.Created, m)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public IEnumerable <mica_vw> Get_mica_vw(string svaId) { List <mica_vw> list = new List <mica_vw>(); string cmdText; cmdText = string.Format("SELECT entity_id, field_sva_comment_value, field_sva_script_value, field_sva_status_value FROM mica_vw where entity_id = ({0})", svaId); try { using (MySqlConnection cn = new MySqlConnection(connStr)) { //using (SqlCommand cmd = new SqlCommand(spName, cn)) using (MySqlCommand cmd = new MySqlCommand(cmdText, cn)) { //cmd.CommandType = CommandType.StoredProcedure; cmd.CommandType = CommandType.Text; cn.Open(); using (MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.Default)) { if (rdr.HasRows) { while (rdr.Read()) { mica_vw m = new mica_vw(); m.Id = 1; m.entity_id = rdr["entity_id"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["entity_id"]); m.field_sva_comment_value = (rdr["field_sva_comment_value"] == DBNull.Value) ? string.Empty : (string)rdr["field_sva_comment_value"]; m.field_sva_script_value = (rdr["field_sva_script_value"] == DBNull.Value) ? string.Empty : (string)rdr["field_sva_script_value"]; m.field_sva_status_value = (rdr["field_sva_status_value"] == DBNull.Value) ? string.Empty : (string)rdr["field_sva_status_value"]; list.Add(m); } } return(list); } } } } catch (Exception ex) { string x = ex.Message; return(null); } }