Beispiel #1
0
        public bool DeleteMovie(int id)
        {
            var movie = _context.Movies.Find(id);

            if (movie == null)
            {
                return(false);
            }

            try
            {
                _context.Remove(movie);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
            catch (DbUpdateException)
            {
                return(false);
            }

            return(true);
        }
        public void RemoveMovie(int id)
        {
            CinemaMovie movieFromDb = _cinemaDbContext.CinemaMovies.FirstOrDefault(x => x.MovieId == id);

            if (movieFromDb != null)
            {
                _cinemaDbContext.Remove(movieFromDb);
                _cinemaDbContext.SaveChanges();
            }
        }
Beispiel #3
0
        public void DeleteUser(int id)
        {
            CinemaUser userFromDb = _cinemaDbContext.Users.FirstOrDefault(x => x.UserId == id);

            if (userFromDb != null)
            {
                _cinemaDbContext.Remove(userFromDb);
                _cinemaDbContext.SaveChanges();
            }
        }
        public IActionResult Delete(int id)
        {
            var movie = _dbContext.Movies.Find(id);

            if (movie == null)
            {
                return(NotFound("No record found against this id"));
            }

            _dbContext.Remove(movie);
            _dbContext.SaveChanges();

            return(Ok("Record Deleted"));
        }
Beispiel #5
0
 public bool Delete(int id)
 {
     try
     {
         Director director = _cinemaDbContext.Director.Single(x => x.DirectorId == id);
         _cinemaDbContext.Remove(director).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         _cinemaDbContext.SaveChanges();
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
        public IEnumerable <Employee> Delete(int id)
        {
            try
            {
                Employee employee = _cinemaDbContext.Employee.Single(x => x.EmployeeId == id);
                _cinemaDbContext.Remove(employee).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                _cinemaDbContext.SaveChanges();

                return(_cinemaDbContext.Employee.ToList());
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }
        public bool Delete(int id)
        {
            try
            {
                Snack snack = _cinemaDbContext.Snack.Single(x => x.SnackId == id);
                _cinemaDbContext.Remove(snack).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                _cinemaDbContext.SaveChanges();
            }
            catch (System.Exception)
            {
                return(false);
            }

            return(true);
        }
        public IEnumerable <Film> Delete(int id)
        {
            try
            {
                Film film = _cinemaDbContext.Film.Single(x => x.FilmId == id);
                _cinemaDbContext.Remove(film).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                _cinemaDbContext.SaveChanges();

                return(_cinemaDbContext.Film.ToList());
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }
 public void Delete(Reservation reservation)
 {
     _dbContext.Remove(reservation);
 }
Beispiel #10
0
 public void Delete(TEntity entityToBeDeleted)
 {
     cinemaDbContext.Remove(entityToBeDeleted);
 }