public List <SmallTextListDataModel> getSkillsByTopicByUserId(int userid, int defaultId) { List <SmallTextListDataModel> list = new List <SmallTextListDataModel>(); using (SqlConnection aSqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "get_CareerAdjective_skillsByTopic"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("userId", userid); cmd.Parameters.AddWithValue("defaultId", defaultId); cmd.Connection = aSqlConnection; aSqlConnection.Open(); SqlDataReader aSqlDataReader = cmd.ExecuteReader(); SmallTextListDataModel aSmallTextListDataModel = new SmallTextListDataModel(); while (aSqlDataReader.Read()) { aSmallTextListDataModel.Id = Convert.ToInt32(aSqlDataReader["id"].ToString()); aSmallTextListDataModel.ParentId = Convert.ToInt32(aSqlDataReader["parentId"].ToString()); aSmallTextListDataModel.Data = aSqlDataReader["data"].ToString(); aSmallTextListDataModel.Description = aSqlDataReader["description"].ToString(); } list.Add(aSmallTextListDataModel); } } return(list); }
public HttpResponseMessage UpdateSmallTextListDataModel(int id, [FromBody] SmallTextListDataModel smallTextListDataModel) { if (smallTextListDataModel == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "data with Id = " + id.ToString() + "not found to update")); } try { commonGateway.UpdateSmallTextListDataModel(smallTextListDataModel); return(Request.CreateResponse(HttpStatusCode.OK, smallTextListDataModel)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public int UpdateSmallTextListDataModel(SmallTextListDataModel smallTextListDataModel /*int userid, int defaultId*/) { int returnBool = 0; using (SqlConnection aSqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "Update_SmallTextListData"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("id", smallTextListDataModel.Id); cmd.Parameters.AddWithValue("parentId", smallTextListDataModel.ParentId); cmd.Parameters.AddWithValue("data", smallTextListDataModel.Data); cmd.Parameters.AddWithValue("description", smallTextListDataModel.Description); cmd.Parameters.Add("returnBool", SqlDbType.Int); cmd.Parameters["returnBool"].Direction = ParameterDirection.Output; cmd.Connection = aSqlConnection; try { aSqlConnection.Open(); Object obj = cmd.ExecuteReader(); returnBool = Convert.ToInt32(cmd.Parameters["returnBool"].Value); } catch (Exception ex) { //throw error } /*finally * { * aSqlConnection.Close(); * }*/ } } return(returnBool); }