Example #1
0
        public HttpResponseMessage Put(CellPhoneUpdateRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            SuccessResponse response = new SuccessResponse();

            _svc.Put(model);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Example #2
0
        public void Put(CellPhoneUpdateRequest model)
        {
            using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ViaConnection"].ConnectionString))
            {
                con.Open(); //Open Connection Here
                SqlCommand cmd = con.CreateCommand();

                cmd.CommandText = "dbo.iPhone_Update"; //Sets the name of the stored procedure
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", model.Id);  //HERE WE ADD ID FROM UPDATE REQUEST
                cmd.Parameters.AddWithValue("@Model", model.Model);
                cmd.Parameters.AddWithValue("@Price", model.Price);

                // 5. Call ExecuteNonQuery to send command
                cmd.ExecuteNonQuery();
            }
        }