public IHttpActionResult Put(Sold_object todo) { if (Sold_objectDAO.Update(todo)) { return(Ok()); } return(BadRequest()); }
//Add sold_object public static Sold_object Insert(Sold_object todo) { using (SqlConnection connection = DataBase.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(INSERT, connection); command.Parameters.AddWithValue("@finalPrice", todo.finalPrice); command.Parameters.AddWithValue("@nameObject", todo.nameObject); command.Parameters.AddWithValue("@catObject", todo.catObject); int id = Int32.Parse(command.ExecuteScalar().ToString()); todo.idObject = id; } return(todo); }
//Get with id public static Sold_object Get(int id) { Sold_object m = null; using (SqlConnection connection = DataBase.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(GET, connection); command.Parameters.AddWithValue("@idObject", id); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { m = new Sold_object(reader); } } return(m); }
public static bool Update(Sold_object todo) { bool state = false; using (SqlConnection connection = DataBase.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(UPDATE, connection); command.Parameters.AddWithValue("@finalPrice", todo.finalPrice); command.Parameters.AddWithValue("@nameObject", todo.nameObject); command.Parameters.AddWithValue("@catObject", todo.catObject); state = command.ExecuteNonQuery() != 0; } return(state); }
public Sold_object Post(Sold_object todo) { return(Sold_objectDAO.Insert(todo)); }