Esempio n. 1
0
        public IActionResult DeleteRating(RatingModel ratingmodel)
        {
            _dbContext.Remove(ratingmodel).State = EntityState.Deleted;
            //ViewData["MovieId"] = new SelectList(_Dbcontext.MovieModels, "MovieId", "MovieName");
            _dbContext.SaveChanges();

            return(RedirectToAction("index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> Delete(string id)
        {
            Movie movie = await _movieDB.Movies.FirstOrDefaultAsync(m => m.Id == id);

            _movieDB.Remove(movie);
            await _movieDB.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        //  Upon deletion of movie, delete from database and direct to confirmation page
        public IActionResult DeleteMovie(int movieId)
        {
            //  Delete from database
            Movie targetMovie = _context.Movies.Where(m => m.MovieId == movieId).FirstOrDefault();

            _context.Remove(targetMovie);
            _context.SaveChanges();
            return(View("DeleteConfirmation", targetMovie));
        }
Esempio n. 4
0
        public IActionResult Entry(Movie movie = null, string type = "", int movieId = -1)
        {
            //this only takes us the success screen if the information is entered correctly. this protects from people using something like postman to enter in values we don't want
            if (type == "remove")
            {
                movie = _context.Movies.FirstOrDefault(m => m.MovieID == movieId);
                if (movie != null)
                {
                    _context.Remove(movie);
                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
                else
                {
                    return(View("Error"));
                }
            }
            else if (!ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                Movie searchedMovie = _context.Movies.FirstOrDefault(m => m.MovieID == movieId);
                if (searchedMovie != null)
                {
                    //the movie already exists so it's an edit
                    //_context.Remove(searchedMovie);
                    //_context.SaveChanges();

                    //_context.Movies.Add(movie);

                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Rating   = movie.Rating;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Director = movie.Director;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Edited   = movie.Edited;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Year     = movie.Year;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Title    = movie.Title;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).LentTo   = movie.LentTo;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Notes    = movie.Notes;
                    _context.Movies.FirstOrDefault(m => m.MovieID == movieId).Category = movie.Category;

                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
                else
                {
                    //commenting out old way
                    //Storage.AddMovie(movie);
                    //the movie is a n
                    _context.Movies.Add(movie);
                    _context.SaveChanges();
                    return(View("Confirmation", movie));
                }
            }
        }
 public IActionResult DeleteLocation(LocationModel mylocation)
 {
     _dbContext.Remove(mylocation).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
     _dbContext.SaveChanges();
     return(View("Index"));
 }
Esempio n. 6
0
 public IActionResult DeleteTheatre(TheatreModel myTheatre)
 {
     _dbContext.Remove(myTheatre).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
     _dbContext.SaveChanges();
     return(View("Index"));
 }