public IHttpActionResult Put(BlackListTutor black)
 {
     if (BlackListTutorDAO.Update(black))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Beispiel #2
0
        public static BlackListTutor Insert(BlackListTutor black)
        {
            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(INSERT, connection);

                command.Parameters.AddWithValue("@idTutor", black.IdTutor);
                command.Parameters.AddWithValue("@dateBeg", black.DateBeg);
                command.Parameters.AddWithValue("@dateEnd", black.DateEnd);

                int id = (int)command.ExecuteScalar();
                black.Id = id;
            }

            return(black);
        }
Beispiel #3
0
        public static bool Update(BlackListTutor black)
        {
            bool state = false;

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

                command.Parameters.AddWithValue("@idTutor", black.IdTutor);
                command.Parameters.AddWithValue("@dateBeg", black.DateBeg);
                command.Parameters.AddWithValue("@dateEnd", black.DateEnd);
                command.Parameters.AddWithValue("@id", black.Id);

                state = command.ExecuteNonQuery() != 0;
            }
            return(state);
        }
Beispiel #4
0
        public static BlackListTutor Get(int id)

        {
            BlackListTutor black = null;

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

                command.Parameters.AddWithValue("@id", id);

                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    black = new BlackListTutor(reader);
                }
            }

            return(black);
        }
 public BlackListTutor Post(BlackListTutor black)
 {
     return(BlackListTutorDAO.Insert(black));
 }