コード例 #1
0
 public IHttpActionResult Put(Sold_object todo)
 {
     if (Sold_objectDAO.Update(todo))
     {
         return(Ok());
     }
     return(BadRequest());
 }
コード例 #2
0
        //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);
        }
コード例 #3
0
        //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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public Sold_object Post(Sold_object todo)
 {
     return(Sold_objectDAO.Insert(todo));
 }