예제 #1
0
        public ActionResult AddComment(string message)
        {
            Session session = new Session
            {
                Session_id = (string)Session["session_id"]
            };

            User user = new User
            {
                Id      = (int)Session["user_id"],
                Session = session
            };

            Comment comment = new Comment
            {
                Message          = message,
                Entertainment_Id = (int)Session["movie_id"],
                User             = user
            };

            eS.InsertComment(comment);
            Movie movie = eS.GetMovieById((int)Session["movie_id"]);

            Session["movie_id"] = movie.Id;

            return(View("Movie2", movie));
        }
예제 #2
0
        public ActionResult AddComment(string message)
        {
            Comment comment = new Comment
            {
                Message          = message,
                Entertainment_Id = 1,
                User             = 1
            };


            eS.InsertComment(comment);


            return(View("Movie2")); //return some view to the user
        }
예제 #3
0
        public void InsertComment()
        {
            Console.WriteLine("TestAddToMyList initiated");
            Console.WriteLine("---------------------------");

            //Arrange
            SessionDB sDB              = new SessionDB();
            int       person_id        = 1;
            int       user_id          = 1;
            int       entertainment_id = 1;
            string    message          = "Awww YEAH!";

            //Act
            Session sessiondb       = sDB.FindSession(person_id);
            EntertainmentService es = new EntertainmentService();
            Session session         = new Session
            {
                Id         = sessiondb.Id,
                Session_id = sessiondb.Session_id
            };

            User user = new User
            {
                Id      = user_id,
                Session = session
            };

            Comment comment = new Comment
            {
                Entertainment_Id = entertainment_id,
                Message          = message,
                User             = user
            };

            es.InsertComment(comment);
            Movie          movie    = es.GetMovieById(entertainment_id);
            List <Comment> comments = movie.Comments;

            //Assert
            Assert.AreEqual(3, comments.Count);

            Console.WriteLine("TestAddToMyList complete");
            Console.WriteLine("--------------------------");
            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            EntertainmentDB           edb = new EntertainmentDB();
            EntertainmentService      es  = new EntertainmentService();
            EntertainmentAdminService eas = new EntertainmentAdminService();
            Service1  ss  = new Service1();
            SessionDB sDB = new SessionDB();

            //List<Entertainment> temp = edb.GetAllEntertainments();
            //foreach (Entertainment ent in temp)
            //{
            //    Console.WriteLine(ent.Id);
            //    Console.WriteLine(ent.Title);
            //    Console.WriteLine(ent.ReleaseDate);
            //}

            //edb.GetPersonalEntertainments(1);

            List <Entertainment> temp2 = es.FindAllEntertainments();

            foreach (Entertainment ent2 in temp2)
            {
                Console.WriteLine(ent2.Id);
                Console.WriteLine(ent2.Title);
                Console.WriteLine(ent2.ReleaseDate);
            }

            //List<Genre> genres = edb.GetAllGenres();
            //foreach (Genre genre in genres)
            //{
            //    Console.WriteLine(genre.Id);
            //    Console.WriteLine(genre.Name);
            //}

            //List<Country> countries = edb.GetAllCountries();
            //foreach (Country country in countries)
            //{
            //    Console.WriteLine(country.Id);
            //    Console.WriteLine(country.Name);
            //}

            //Movie movie = new Movie
            //{
            //    Title = "Iron Man 4",
            //    Genre = edb.FindGenreByName("Action"),
            //    Country = edb.FindCountryByName("USA"),
            //    Language = edb.FindLanguageByName("English"),
            //    ReleaseDate = DateTime.Now,
            //    StoryLine = "Something Explode",
            //    FilmingLocation = "New York",
            //    Information = "nice",
            //    //IsMovie = true
            //};
            //eas.StartInsertMovieTransaction(movie);


            //Movie testmovie = es.GetMovieById(1);
            //Console.WriteLine(testmovie.Title);

            Movie findMovie = es.GetMovieById(1);

            Console.WriteLine(findMovie.Title);
            Console.WriteLine(findMovie.Country.Name);
            Console.WriteLine(findMovie.Language.Name);
            Console.WriteLine(findMovie.Genre.Name);

            //long ticks = DateTime.Now.Ticks;
            //byte[] bytes = BitConverter.GetBytes(ticks);
            //string id = Convert.ToBase64String(bytes).Replace('+', '_').Replace('/', '-').TrimEnd('=');
            //Console.WriteLine(id);

            User user = new User
            {
                Password = "******",
                UserName = "******"
            };

            User u = ss.LoginConfirmation(user);

            Console.WriteLine(u.Id);
            Console.WriteLine(u.Session.Session_id);



            Session sessiondb = sDB.FindSession(1);
            Session session   = new Session
            {
                Id         = sessiondb.Id,
                Session_id = sessiondb.Session_id
            };

            User user1 = new User
            {
                Id      = 1,
                Session = session
            };

            Comment comment = new Comment
            {
                Entertainment_Id = 1,
                Message          = "Awwww YEAH!",
                User             = user1
            };

            es.InsertComment(comment);
        }