Ejemplo n.º 1
0
        public void UpdateMood(MoodBoardUpdateRequestModel req)
        {
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("MoodBoard_Update", con);

                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@mood", req.Mood);
                cmd.Parameters.AddWithValue("@soundByteURL", req.SoundByteUrl);
                cmd.Parameters.AddWithValue("@icon", req.Icon);
                cmd.Parameters.AddWithValue("@id", req.Id);

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
        public HttpResponseMessage UpdateMood(MoodBoardUpdateRequestModel model)
        {
            if (model == null)
            {
                ModelState.AddModelError("", "You did not send any mood data!");
            }

            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest,
                           ModelState
                           ));
            }

            IMoodBoardService moodBoardService = new MoodBoardService();

            moodBoardService.UpdateMood(model);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }