Esempio n. 1
0
        public UnitTest1()
        {
            var options = new DbContextOptionsBuilder <MovieDataContext>().UseInMemoryDatabase(databaseName: "movie_tests").Options;

            //db = MovieRepository();
            db = new MovieDataContext(options);

            db.Movies.AddRange(
                new Movie
            {
                Title    = "The Dark Knight",
                DateSeen = new DateTime(2020, 5, 20),
                Genre    = "Action",
                Rating   = 9
            },
                new Movie
            {
                Title    = "Dude Where's My Car",
                DateSeen = new DateTime(2005, 4, 16),
                Genre    = "Comedy",
                Rating   = 8
            }
                );

            db.SaveChanges();
        }
Esempio n. 2
0
                  public MovieRepository()
                  
        {
                            _dataContext = new MovieDataContext();

                      
        }
Esempio n. 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        MovieDataContext db   = new MovieDataContext();
        Love             love = new Love();

        love.MovieId = TextBox1.Text;
        db.Love.InsertOnSubmit(love);
        db.SubmitChanges();
        Response.Write("<script type='text/javascript'>alert('收藏成功!正在跳转到登陆页面');location.href='Mylove.aspx';</script> ");
    }
Esempio n. 4
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     using (var db = new MovieDataContext())
     {
         if (!db.DatabaseExists())
         {
             db.CreateDatabase();
         }
     }
 }
Esempio n. 5
0
                  public ActionResult Index()
                  
        {
                           var dataContext = new MovieDataContext();
                           var movies      = from m in dataContext.Movies
                                                                 select m;

                           return View(movies);

                      
        }
Esempio n. 6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        MovieDataContext db   = new MovieDataContext();
        Ques             ques = new Ques();

        ques.username = txtName.Text;
        ques.password = txtPassword.Text;
        db.Ques.InsertOnSubmit(ques);
        db.SubmitChanges();
        Response.Write("<script type='text/javascript'>alert('注册成功!正在跳转到登陆页面');location.href='Login.aspx';</script> ");
    }
                  public ActionResult Index()
                  
        {
                           var dataContext = new MovieDataContext();
            int count = (from row in dataContext.Movies
                                             where row.IsEnquiry == true
                         select row).Count();

            ViewBag.ItemCount = count;
                           return View();

                      
        }
Esempio n. 8
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        MovieDataContext db       = new MovieDataContext();
        admin            a        = new admin();
        string           UserID   = txtname.Text;
        string           password = txtpassword.Text;
        var p = from c in db.admin
                where c.user == UserID && c.pwd == password
                select c;

        if (p.Count() != 0)
        {
            Session["user"] = UserID;
            Session["pwd"]  = password;
            this.Response.Write(" <script language=javascript>alert('登录成功!');location.href='RoleUsers.aspx';</script> ");
        }
    }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MovieDataContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MovieDataContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Name        = "When Harry Met Sally",
                    ReleaseYear = 1989,
                    Description = "Romantic Comedy"
                },

                    new Movie
                {
                    Name        = "Ghostbusters ",
                    ReleaseYear = 1984,
                    Description = "Comedy"
                },

                    new Movie
                {
                    Name        = "Ghostbusters 2",
                    ReleaseYear = 1986,
                    Description = "Comedy"
                },

                    new Movie
                {
                    Name        = "Rio Bravo",
                    ReleaseYear = 1959,
                    Description = "Western"
                }
                    );
                context.SaveChanges();
            }
        }
Esempio n. 10
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        MovieDataContext db       = new MovieDataContext();
        Ques             Q        = new Ques();
        string           UserID   = txtName.Text;
        string           password = txtPassword.Text;
        var p = from c in db.Ques
                where c.username == UserID && c.password == password
                select c;

        if (p.Count() != 0)
        {
            Session["username"] = UserID;
            Session["password"] = password;
            this.Response.Write(" <script language=javascript>alert('登录成功!');location.href='Home.aspx';</script> ");
        }
        else
        {
            Response.Write(" <script language=javascript>alert('您的账号或密码错误!');location.href='Login.aspx';</script> ");
        }
    }
Esempio n. 11
0
    protected void AddMovieInfo(int id)
    {
        int isExit = 0;

        for (int j = 0; j < Profile.Cart.movieName.Count; j++)
        {
            if (id == (int)Profile.Cart.movieId[j])
            {
                isExit        = 1;
                lblError.Text = "您已收藏本电影";
            }
        }
        if (isExit == 0)
        {
            MovieDataContext db = new MovieDataContext();
            var movie           = (from m in db.MovieInfo
                                   where m.id == id
                                   select m).First();
            Profile.Cart.movieId.Add(movie.id);
            Profile.Cart.movieName.Add(movie.name);
            Profile.Save();
        }
    }
Esempio n. 12
0
 public DataService()
 {
     _db = new MovieDataContext();
 }
 public MovieController(MovieDataContext context)
 {
     _context = context;
 }
Esempio n. 14
0
 public MoviesController()
 {
     _dataContext = new MovieDataContext();
 }