public HttpResponseMessage UpdateOnlineLinkDataModel(int id, [FromBody] OnlineLinkDataModel onlineLinkDataModel) { if (onlineLinkDataModel == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "data with Id = " + id.ToString() + "not found to update")); } try { commonGateway.UpdateOnlineLinkDataModel(onlineLinkDataModel); return(Request.CreateResponse(HttpStatusCode.OK, onlineLinkDataModel)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public int UpdateOnlineLinkDataModel(OnlineLinkDataModel onlineLinkDataModel /*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_OnlineLinkData"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("id", onlineLinkDataModel.Id); cmd.Parameters.AddWithValue("parentId", onlineLinkDataModel.ParentId); cmd.Parameters.AddWithValue("title", onlineLinkDataModel.Title); cmd.Parameters.AddWithValue("link", onlineLinkDataModel.Link); cmd.Parameters.AddWithValue("icon", onlineLinkDataModel.IconLink); cmd.Parameters.AddWithValue("description", onlineLinkDataModel.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); }