示例#1
0
        public IActionResult AddMovies()
        {
            AddMovieModel     movieModel = new AddMovieModel();
            AddMovieViewModel pageData   = movieModel.GetData();

            return(View(pageData));
        }
示例#2
0
        public IActionResult Delete(int id = 0)
        {
            //finding the movieId and deleting it and saving the database
            AddMovieModel _movie = context.Movies.Find(id);

            context.Movies.Remove(_movie);
            context.SaveChanges();
            return(RedirectToAction("ShowMovies"));
        }
        public IActionResult Edit(AddMovieModel movie)
        {
            if (ModelState.IsValid)
            {
                context.Movies.Update(movie);
                context.SaveChanges();
                Response.Redirect("MoviesList");
            }

            return(View());
        }
示例#4
0
 public IActionResult Edit(AddMovieModel _mov)
 {
     if (ModelState.IsValid)
     {
         //modifying the entry and saving the changes
         context.Entry(_mov).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("ShowMovies"));
     }
     return(View(_mov));
 }
示例#5
0
        public IActionResult Edit(int id = 0)
        {
            //finding the movieId then autopopulating the edit page with that movie's info
            AddMovieModel _mov = context.Movies.Find(id);

            if (_mov == null)
            {
                //return HttpNotFound();
            }
            return(View(_mov));
        }
示例#6
0
        public IActionResult AddMovie(AddMovieModel m)
        {
            if (ModelState.IsValid)
            {
                //update database
                context.Movies.Add(m);
                context.SaveChanges();
                return(RedirectToAction("ShowMovies"));
            }

            return(View(m));
        }
示例#7
0
        public async Task <ActionResult <MovieDetailsModel> > Add([FromBody] AddMovieModel model, CancellationToken cancellationToken)
        {
            var command = new AddMovieCommand(model.Id.Value);

            var result = await Dispatcher.DispatchAsync(command, cancellationToken);

            if (result is null)
            {
                return(NotFound());
            }

            var url = Url.Action(nameof(GetById), new { id = result.Id });

            return(Created(url, result));
        }