示例#1
0
        public void UpdateMovie()
        {
            MovieData moviedata = new MovieData();
            MovieData movienew  = movieDataSource.GetDataById(10);

            moviedata.Title = "Insert Unit Test";
            movie.UpdateMovie(moviedata, 10);
            string NewTitle = movieDataSource.GetDataById(10).Title;

            Assert.AreEqual(moviedata.Title, NewTitle);
        }
 public IHttpActionResult GetMovie(int id)
 {
     try
     {
         var data = _dataSource.GetDataById(id);
         return(Ok(data));
     }
     catch (Exception ex)
     {
         return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)));
     }
 }
示例#3
0
 public MovieData GetMovieById(int id)
 {
     try
     {
         var allMovies = GetAllMovies();
         var movie     = allMovies.FirstOrDefault(r => r.MovieId == id);
         if (movie == null)
         {
             movie = _dataSrc.GetDataById(id);
             if (movie != null)
             {
                 return(movie);
             }
             return(null);
         }
         return(movie);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#4
0
 /// <summary>
 /// Gets the movie information by movie Id
 /// <para>Id of the movie to get details of</para>
 /// </summary>
 /// <returns>Returns object of moviedata having all the info</returns>
 public MovieData GetDataById(int Id)
 {
     return(movieDataSource.GetDataById(Id));
 }
        /// <summary>
        ///     Gets the movie by identifier.
        /// </summary>
        /// <param name="movieId">The movie identifier.</param>
        /// <returns>MovieDto</returns>
        public MovieDto GetMovieById(int movieId)
        {
            var movie = _dataSource.GetDataById(movieId);

            return(movie?.ToDto());
        }