protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new ReviewContext())
     {
         if (IsPostBack)
         {
             var movie = new Movie
             {
                 Title       = Request.Form["title"],
                 Genre       = Request.Form["genre"],
                 IMDBUrl     = Request.Form["imdburl"],
                 ReleaseDate = Request.Form["releasedate"]
             };
             db.Movies.Add(movie);
             db.SaveChanges();
             Response.Redirect("MovieList.aspx");
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int movieId = int.Parse(Request.QueryString["id"]);

            using (var db = new ReviewContext())
            {
                movieInstance = db.Movies.First(n => n.Id == movieId);
                if (IsPostBack)
                {
                    movieInstance.Title           = Request.Form["title"];
                    movieInstance.Genre           = Request.Form["genre"];
                    movieInstance.IMDBUrl         = Request.Form["imdburl"];
                    movieInstance.ReleaseDate     = Request.Form["releasedate"];
                    db.Entry(movieInstance).State = EntityState.Modified;
                    db.SaveChanges();
                    Response.Redirect("MovieList.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int movieId = int.Parse(Request.QueryString["id"]);

            using (var db = new ReviewContext())
            {
                movieInstance = db.Movies.First(n => n.Id == movieId);
                if (IsPostBack)
                {
                    var review = new Review
                    {
                        ReviewerName       = Request.Form["reviewername"],
                        Movie              = movieInstance,
                        Rating             = int.Parse(Request.Form["rating"]),
                        ReviewerAge        = int.Parse(Request.Form["reviewerage"]),
                        ReviewerOccupation = Request.Form["revieweroccupation"]
                    };
                    db.Reviews.Add(review);
                    db.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
        }