Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new MovieReviewContext())
     {
         Movies = db.Movies.ToList();
     }
 }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new MovieReviewContext())
     {
         Reviews = db.Reviews.Include("Movie").ToList();
     }
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var movieId = int.Parse(Request.QueryString["id"]);

            using (var db = new MovieReviewContext())
            {
                movieInstance = db.Movies.First(n => n.Id == movieId);
                if (IsPostBack)
                {
                    movieInstance.Title       = Request.Form["title"];
                    movieInstance.Genre       = Request.Form["genre"];
                    movieInstance.IMDBLink    = Request.Form["imdb"];
                    movieInstance.ReleaseDate = Request.Form["release"];

                    db.Entry(movieInstance).State = EntityState.Modified;
                    db.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form.AllKeys.Contains("title"))
            {
                using (var db = new MovieReviewContext())
                {
                    var addMovie = new Movie
                    {
                        Title       = Request.Form["title"],
                        Genre       = Request.Form["genre"],
                        IMDBLink    = Request.Form["imdb"],
                        ReleaseDate = Request.Form["release"]
                    };

                    db.Movies.Add(addMovie);
                    db.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form.AllKeys.Contains("name"))
            {
                using (var db = new MovieReviewContext())
                {
                    var addReview = new Review
                    {
                        Name       = Request.Form["name"],
                        MovieId    = int.Parse(Request.Form["reviewId"]),
                        Rating     = int.Parse(Request.Form["rating"]),
                        Age        = int.Parse(Request.Form["age"]),
                        Gender     = Request.Form["gender"],
                        Occupation = Request.Form["occupation"]
                    };

                    db.Reviews.Add(addReview);
                    db.SaveChanges();
                    Response.Redirect("ReviewList.aspx");
                }
            }

            var movieId = int.Parse(Request.QueryString["id"]);

            using (var db = new MovieReviewContext())
            {
                movieInstance = db.Movies.First(n => n.Id == movieId);
                if (IsPostBack)
                {
                    movieInstance.Title       = Request.Form["title"];
                    movieInstance.Genre       = Request.Form["genre"];
                    movieInstance.IMDBLink    = Request.Form["imdb"];
                    movieInstance.ReleaseDate = Request.Form["release"];
                }
            }
        }