예제 #1
0
 public IHttpActionResult Put(Seller_user todo)
 {
     if (Seller_userDAO.Update(todo))
     {
         return(Ok());
     }
     return(BadRequest());
 }
예제 #2
0
        //Return seller by id
        public static Seller_user Get(int id)
        {
            Seller_user m = null;

            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(GET, connection);
                command.Parameters.AddWithValue("@idSeller", id);
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    m = new Seller_user(reader);
                }
            }
            return(m);
        }
예제 #3
0
        //Add seller
        public static Seller_user Insert(Seller_user todo)
        {
            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(INSERT, connection);

                command.Parameters.AddWithValue("@username", todo.username);
                command.Parameters.AddWithValue("@nbSales", todo.nbSales);
                command.Parameters.AddWithValue("@positiveVote", todo.positiveVote);
                command.Parameters.AddWithValue("@negativeVote", todo.negativeVote);
                command.Parameters.AddWithValue("@idUser", todo.idUser);

                todo.idSeller = (int)command.ExecuteScalar();
            }
            return(todo);
        }
예제 #4
0
        //Update a seller_user
        public static bool Update(Seller_user todo)
        {
            bool state = false;

            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(UPDATE, connection);

                command.Parameters.AddWithValue("@username", todo.username);
                command.Parameters.AddWithValue("@nbSales", todo.nbSales);
                command.Parameters.AddWithValue("@positiveVote", todo.positiveVote);
                command.Parameters.AddWithValue("@negativeVote", todo.negativeVote);
                command.Parameters.AddWithValue("@idUser", todo.idUser);

                state = command.ExecuteNonQuery() != 0;
            }
            return(state);
        }
예제 #5
0
 public Seller_user Post(Seller_user todo)
 {
     return(Seller_userDAO.Insert(todo));
 }