コード例 #1
0
        public ActionResult <Films> Get(string id)
        {
            var film = _service.GetById(id);

            if (film == null)
            {
                return(NotFound());
            }

            return(film);
        }
コード例 #2
0
        public void GetByIdShouldReturnFilmWithCorrectIdNumber()
        {
            var options = new DbContextOptionsBuilder <FilmeDbContext>()
                          .UseInMemoryDatabase(databaseName: nameof(GetByIdShouldReturnFilmWithCorrectIdNumber))
                          .Options;

            using (var context = new FilmeDbContext(options))
            {
                var filmService = new FilmService(context);
                var addedFilm   = filmService.Create(new Lab3.ViewModels.FilmPostModel
                {
                    Title       = "Testare",
                    Director    = "dir1",
                    DateAdded   = new DateTime(),
                    Duration    = 100,
                    Description = "asdvadfbdbsb",
                    Genre       = "Comedy",
                    ReleaseYear = 2000,
                    Rating      = 3,
                    Watched     = 0
                }, null);

                var theFilm = filmService.GetById(1);
                Assert.AreEqual("Testare", theFilm.Title);
            }
        }
 public ActionResult <ResponseObject <Film> > GetFilm(string id)
 {
     return(_businessware.GetById(id));
 }