Exemplo n.º 1
0
 public IHttpActionResult Put(Seller_user todo)
 {
     if (Seller_userDAO.Update(todo))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public Seller_user Post(Seller_user todo)
 {
     return(Seller_userDAO.Insert(todo));
 }