public IHttpActionResult postVacancyPosts([FromBody] Vacancypost vPost) { try { String query = " INSERT INTO Vacancyposts(userID, title, benefit, salary, jobDescription, requirement, jobType, upVote, downVote)" + "VALUES(" + vPost.userID + ",'" + vPost.title + "','" + vPost.benefit + "','" + vPost.salary + "','" + vPost.jobDescription + "','" + vPost.requirement + "', '" + vPost.jobType + "','" + vPost.upVote + "', '" + vPost.downVote + "'); "; c = new SqlCommand(query, con); con.Open(); c.ExecuteNonQuery(); con.Close(); return(Ok()); } catch (Exception e) { return(NotFound()); } }
private void getPosts(List <Vacancypost> list, SqlDataReader reader) { while (reader.Read()) { int id = Int32.Parse(reader[0].ToString()); int Uid = Int32.Parse(reader[1].ToString()); int salary = Int32.Parse(reader[4].ToString()); int upVote = Int32.Parse(reader[8].ToString()); int downVote = Int32.Parse(reader[9].ToString()); Vpost = new Vacancypost(id, Uid, upVote, downVote, reader[2].ToString(), reader[3].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), salary); list.Add(Vpost); } reader.Close(); }