Example #1
0
        // GET: Film
        public ActionResult Index()
        {
            var service = new FilmService();
            var model   = service.GetFilms().OrderBy(x => x.Title);

            return(View(model));
        }
Example #2
0
 private void CheckCanDeleteFilm()
 {
     if (CurrentFilm != null && CurrentFilm.FilmId != null)
     {
         var isFilmExist = _filmService.GetFilms().Any(x => x.FilmId == CurrentFilm.FilmId);
         if (isFilmExist)
         {
             CanDeleteFilm = true;
         }
         else
         {
             CanDeleteFilm = false;
         }
     }
     else
     {
         CanDeleteFilm = false;
     }
 }
Example #3
0
        public void TestMethod1()
        {
            filmService.AddFilm(new Film()
            {
                Id = 2, Nombre = "Gladiator"
            });
            var list = filmService.GetFilms();

            Assert.IsTrue(list.Count > 0);
        }
Example #4
0
        public async void GetFilms_Returns_Correct_Film_From_Search()
        {
            // Arrange
            var    filmService = new FilmService();
            string query       = "The NeverEnding Story";

            // Act
            Payload actual = await filmService.GetFilms(query);

            // Assert
            Assert.Equal(actual.Search[0].Title, query);
        }
Example #5
0
        public async void GetFilms_Returns_A_List_Of_Films()
        {
            // Arrange
            var    filmService = new FilmService();
            string query       = "The NeverEnding Story";

            // Act
            Payload actual = await filmService.GetFilms(query);

            // Assert
            Assert.IsType <List <Film> >(actual.Search);
        }
Example #6
0
 private void CheckCanDeleteDirector()
 {
     if (CurrentDirector != null && CurrentDirector.DirectorId != null)
     {
         var isDirectorUsed = _filmService.GetFilms().Any(x => x.DirectorId == CurrentDirector.DirectorId);
         if (!isDirectorUsed)
         {
             CanDeleteDirector = true;
         }
         else
         {
             CanDeleteDirector = false;
         }
     }
     else
     {
         CanDeleteDirector = false;
     }
 }
Example #7
0
        public IActionResult ShowFilmViews(string sortOrder, string sortValue, string name,
                                           List <long> awards, string playwriter, long playwriterId = 0)
        {
            var sortQuery = new SortQuery
            {
                Order = sortOrder ?? FilmConstants.SortAsc,
                Value = sortValue ?? FilmConstants.SortTitle
            };

            var filterQuery = new FilmFilterQuery
            {
                Title        = name,
                PlaywriterId = playwriterId,
                Playwriter   = playwriter,
                Awards       = awards
            };

            return(View(_filmService.GetFilms(sortQuery, filterQuery)));
        }
Example #8
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            FilmService filmService = new FilmService();
            Payload     film        = await filmService.GetFilms("James");

            var title = film.Search[0].Title;

            button.Click += delegate { button.Text = $"The film is: ${title}"; };
            button.Click += delegate { Console.WriteLine(title); };
        }
 public ActionResult <List <Film> > GetFilms() =>
 _filmService.GetFilms("Comedy");
Example #10
0
 public async Task <IEnumerable <Film> > GetFilms()
 {
     return(await _films.GetFilms());
 }
        // GET: Discussion/Create
        public ActionResult CreateFilmDiscussion()
        {
            ViewBag.FilmId = new SelectList(filmService.GetFilms(), "FilmId", "Title");

            return(View());
        }
Example #12
0
        public ActionResult Index()
        {
            var list = filmService.GetFilms();

            return(View());
        }
        static void Main(string[] args)
        {
            initializeNH();
            // get a list of films
            FilmService fs       = new FilmService(_sessionFactory);
            var         filmList = fs.GetFilms(50);

            foreach (var f in filmList)
            {
                Console.WriteLine(f);
            }
            // randomly select a film and return a list of actors in that film
            int          randomItemSequence = new Random().Next(0, filmList.Count);
            Film         randomFilm         = filmList[randomItemSequence];
            List <Actor> actorList          = fs.GetActorsInFilm(randomFilm.Id);

            Console.WriteLine("These actors appeared in the " + randomFilm.ReleaseYear + " rendition of " +
                              randomFilm.Title + ", originally in " +
                              (randomFilm.OriginalLanguage == null ? "an unknown language" : randomFilm.OriginalLanguage.Name) +
                              ".");
            foreach (var a in actorList)
            {
                Console.WriteLine(a.FullName);
            }
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            // querying isn't the only power of NHibernate.
            // here is how to add an actor:
            int muditActorId;

            using (ISession s = _sessionFactory.OpenSession())
            {
                var newActor = new Actor()
                {
                    FirstName  = "Mudit",
                    LastName   = "Singhania",
                    LastUpdate = DateTime.UtcNow
                };
                s.Save(newActor);
                Console.WriteLine("We just saved Mudit as an actor - his key in the database is " + newActor.Id);
                muditActorId = newActor.Id;
            }
            // ...and here's how to later update him
            using (ISession s = _sessionFactory.OpenSession())
            {
                var mudit = s.Get <Actor>(muditActorId);
                mudit.LastUpdate = new DateTime(2018, 1, 1, 13, 33, 0);
                s.Update(mudit);
                s.Flush();
                Console.WriteLine("We just updated Mudit's record");
            }
            // ...and here's how to remove him
            using (ISession s = _sessionFactory.OpenSession())
            {
                var mudit = s.Get <Actor>(muditActorId);
                s.Delete(mudit);
                s.Flush();
                Console.WriteLine("We just removed Mudit with a delete statement");
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }