public List <MoviesReview> hhi()

        {
            MoviesReview        enp     = new MoviesReview();
            List <MoviesReview> listemp = new List <MoviesReview>();
            SqlConnection       con1    = null;

            try
            {
                con1 = new SqlConnection("data source=.;database=MovieReviewDb;integrated security=SSPI");
                con1.Open();
                SqlCommand    cmd2 = new SqlCommand("select * from MoviesReview", con1);
                SqlDataReader sdrd = cmd2.ExecuteReader();
                while (sdrd.Read())
                {
                    enp = new MoviesReview();
                    //enp.UserId = (int)sdrd["UserId"];
                    enp.Username         = (string)sdrd["Username"];
                    enp.MoviewReviewName = (string)sdrd["MoviewReviewName"];
                    enp.MovieId          = (int)sdrd["MovieId"];
                    enp.MovieRating      = (int)sdrd["MovieRating"];
                    //enp.MoviewImageId = (string)sdrd["Password"];
                    enp.Feedback = (string)sdrd["Feedback"];

                    //enp.LastName = (string)sdrd["LastName"];
                    //enp.Email = (string)sdrd["Email"];
                    listemp.Add(enp);
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine("ERROR", Ex);
            }
            return(listemp);
        }
Exemple #2
0
 // Update an existing review
 // PUT /api/MovieReviews/
 public HttpResponseMessage Put([FromBody] MoviesReview review)
 {
     //review.Id = Id;
     Uow.MovieReviews.Update(review);
     Uow.Commit();
     return(new HttpResponseMessage(HttpStatusCode.NoContent));
 }
Exemple #3
0
        // Create a new review
        // POST /api/MovieReviews
        public HttpResponseMessage Post(MoviesReview review, int Id)
        {
            review.MovieId = Id;
            Uow.MovieReviews.Add(review);
            Uow.Commit();

            var response = Request.CreateResponse(HttpStatusCode.Created, review);


            return(response);
        }
        public string MoviesReview(MoviesReview obj)

        {
            SqlConnection con2 = null;

            try
            {
                con2 = new SqlConnection("data source=.;database=MovieReviewDb;integrated security=SSPI");
                con2.Open();
                SqlCommand cmd2 = new SqlCommand("insert into MoviesReview values('" + obj.MoviewReviewName + "'," + obj.MovieId + "," + obj.MovieRating + ", " + obj.MoviewImageId + ",'" + obj.Feedback + "','" + obj.Username + "')", con2);
                cmd2.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
                Console.WriteLine("ERROR", Ex);
            }
            return("inserted");
        }