public ActionResult Put([FromBody] StepsDTO stepsDto)
        {
            if (StepsDAO.Update(stepsDto))
            {
                return(Ok());
            }

            return(BadRequest());
        }
Esempio n. 2
0
        public static StepsDTO Post(StepsDTO step)
        {
            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = connection.CreateCommand();
                command.CommandText = REQ_POST;

                command.Parameters.AddWithValue($@"{FIELD_ID_RECIPE}", step.IdRecipe);
                command.Parameters.AddWithValue($@"{FIELD_STEP}", step.Step);
                command.Parameters.AddWithValue($@"{FIELD_STEPNUMBER}", step.StepNumber);
                step.IdStep = (int)command.ExecuteScalar();
            }

            return(step);
        }
Esempio n. 3
0
        public static bool Update(StepsDTO step)
        {
            bool hasBeenChanged = false;

            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = connection.CreateCommand();
                command.CommandText = REQ_UPDATE;
                command.Parameters.AddWithValue($@"{FIELD_ID_RECIPE}", step.IdRecipe);
                command.Parameters.AddWithValue($@"{FIELD_STEP}", step.Step);
                command.Parameters.AddWithValue($@"{FIELD_ID_STEP}", step.IdStep);
                command.Parameters.AddWithValue($@"{FIELD_STEPNUMBER}", step.StepNumber);
                hasBeenChanged = command.ExecuteNonQuery() == 1;
            }

            return(hasBeenChanged);
        }
 public StepsDTO Post([FromBody] StepsDTO stepsDto)
 {
     return(StepsDAO.Post(stepsDto));
 }