protected void Page_Load(object sender, EventArgs e)
        {
            using (var db = new ReviewContext())
            {
                var movieId = int.Parse(Request.QueryString["id"]);
                movieInstance = db.Movies.First(m => m.Id == movieId);
                reviewList    = db.Reviews.Where(r => r.MovieId == movieId).ToList();

                //if (ratingInt > 10 || ratingInt < 1)
                //{
                //    valid = false;
                //}
                //else
                //{
                //    valid = true;
                //      do stuff
                //}

                /*********************Add New Review***********************/
                if (IsPostBack)
                {
                    int    ratingInt = int.Parse(Request.Form["rating"]);
                    double avgRating = 0
                    ;
                    var review = new Review
                    {
                        Reviewer = Request.Form["name"],
                        Rating   = ratingInt,
                        MovieId  = movieId,
                    };

                    db.Reviews.Add(review);
                    db.SaveChanges();

                    /*********************Repopulate Review List***********************/
                    reviewList.ToList();

                    /*********************Calculate Average***********************/
                    foreach (var reviewInst in reviewList)
                    {
                        avgRating += reviewInst.Rating;
                    }

                    avgRating /= (reviewList.Count() + 1);

                    movieInstance.AverageRating = avgRating;

                    db.Entry(movieInstance).State = EntityState.Modified;

                    db.SaveChanges();

                    avgStr = String.Format("{0:00.0}", avgRating.ToString());
                    Response.Redirect("Default.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var db = new ReviewContext())
            {
                var movieId = int.Parse(Request.QueryString["id"]);
                movieInstance = db.Movies.First(m => m.Id == movieId);

                if (IsPostBack)
                {
                    string title   = Request.Form["title"];
                    string genre   = Request.Form["genre"];
                    string imdbURL = Request.Form["imdbURL"];
                    string release = Request.Form["release"];
                    string img     = Request.Form["img"];

                    if (title != "")
                    {
                        movieInstance.Title = title;
                    }

                    if (genre != "")
                    {
                        movieInstance.Genre = genre;
                    }

                    if (imdbURL != "")
                    {
                        movieInstance.IMDB = imdbURL;
                    }

                    if (img != "")
                    {
                        movieInstance.imgURL = img;
                    }

                    if (release != "")
                    {
                        movieInstance.ReleaseDate = release;
                    }

                    db.Entry(movieInstance).State = EntityState.Modified;
                    db.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
        }