public SingleIntegerModel getPercentageByUserId(int userid, int defaultId) { SingleIntegerModel aSingleIntegerModel = new SingleIntegerModel(); using (SqlConnection aSqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "get_skills_percentage"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("userId", userid); cmd.Parameters.AddWithValue("defaultId", defaultId); cmd.Connection = aSqlConnection; aSqlConnection.Open(); SqlDataReader aSqlDataReader = cmd.ExecuteReader(); while (aSqlDataReader.Read()) { aSingleIntegerModel.Id = Convert.ToInt32(aSqlDataReader["id"].ToString()); aSingleIntegerModel.RepositorychildId = Convert.ToInt32(aSqlDataReader["repositorychildId"].ToString()); aSingleIntegerModel.Data = Convert.ToInt32(aSqlDataReader["data"].ToString()); aSingleIntegerModel.Description = aSqlDataReader["description"].ToString(); } } } return(aSingleIntegerModel); }
public HttpResponseMessage UpdateSingleIntegerModel(int id, [FromBody] SingleIntegerModel singleIntegerModel) { if (singleIntegerModel == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "data with Id = " + id.ToString() + "not found to update")); } try { commonGateway.UpdateSingleIntegerModel(singleIntegerModel); return(Request.CreateResponse(HttpStatusCode.OK, singleIntegerModel)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public int UpdateSingleIntegerModel(SingleIntegerModel singleIntegerModel /*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_SingleIntegerDefault"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("id", singleIntegerModel.Id); cmd.Parameters.AddWithValue("repositorychildId", singleIntegerModel.RepositorychildId); cmd.Parameters.AddWithValue("data", singleIntegerModel.Data); cmd.Parameters.AddWithValue("description", singleIntegerModel.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); }