コード例 #1
0
        public void AddMovieTestNullException()
        {
            CUMovieDto myNullEyxeotionMovie = new CUMovieDto();

            myNullEyxeotionMovie = null;
            Task.WaitAll(Assert.ThrowsExceptionAsync <ArgumentNullException>(() => _MovieService.AddMovie(myNullEyxeotionMovie)));
        }
コード例 #2
0
 public IActionResult AddMovie([FromBody] MovieModel model)
 {
     if (_MovieService.AddMovie(model))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest(new { message = "Movie could not be added." }));
     }
 }
コード例 #3
0
        public IActionResult AddMovie(MovieRequest request)
        {
            var success = _service.AddMovie(request);

            if (success)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #4
0
ファイル: MoviesController.cs プロジェクト: Sytabram/MovieAPI
        public async Task <IActionResult> AddMovie(CUMovieDto newMovie)
        {
            try
            {
                var modelDb = await _moviesService.AddMovie(newMovie);

                return(Created($"movie/{modelDb.Id}", modelDb));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #5
0
 public IActionResult AddMovie(ViewMovies movies)
 {
     {
         var sPath = "C:/Users/m1043011/Pictures/Screenshots/Screenshot (47).png";
         //Open FileStream to read file
         FileInfo   fInfo    = new FileInfo(sPath);
         FileStream fStream  = new FileStream(sPath, FileMode.Open, FileAccess.Read);
         long       numBytes = fInfo.Length;
         //Use BinaryReader to read file stream into byte array.
         BinaryReader br = new BinaryReader(fStream);
         movies.poster = br.ReadBytes((int)numBytes);
         int status = 0;
         foreach (var item in movies.Actors)
         {
             var movie = new Movies {
                 actorid = int.Parse(item.Value), plot = movies.plot, poster = movies.poster, producerid = movies.producerid, yearofrelease = movies.yearofrelease
             };
             status = moviesService.AddMovie(movie);
         }
         ViewBag.SuccessMsg = status == 1 ? "movie created successfully" : "unable to process at this time .. Sorry....";
     }
     return(RedirectToAction("AddMovie"));
 }
コード例 #6
0
 public ((IEnumerable <Movies> movies, IEnumerable <Select> options), string error) AddMovie([FromQuery] string name, [FromQuery] int price, [FromQuery] string url, [FromQuery] string username)
 {
     return(_moviesService.AddMovie(name, price, url, username));
 }
コード例 #7
0
        //IHttpActionResult googlear
        public IHttpActionResult AddMovie(Entities.Movie m)
        {
            _moviesSvc.AddMovie(m);

            return(Ok());
        }