Exemple #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Developer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeveloperExists(Developer.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string[] selectedGenres)
        {
            var newMovie = new Movie();

            if (selectedGenres != null)
            {
                newMovie.MovieGenres = new List <MovieGenre>();
                foreach (var gen in selectedGenres)
                {
                    var genToAdd = new MovieGenre
                    {
                        GenreID = int.Parse(gen)
                    };
                    newMovie.MovieGenres.Add(genToAdd);
                }
            }
            if (await TryUpdateModelAsync <Movie>(
                    newMovie,
                    "Movie",
                    i => i.Title, i => i.Director,
                    i => i.IMDBRatings, i => i.ReleaseDate, i => i.ProductionCoID, i => i.DeveloperID))
            {
                _context.Movie.Add(newMovie);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateAssignedGenreData(_context, newMovie);
            return(Page());
        }
Exemple #3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Genre.Add(Genre);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Developer = await _context.Developer.FindAsync(id);

            if (Developer != null)
            {
                _context.Developer.Remove(Developer);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Genre = await _context.Genre.FindAsync(id);

            if (Genre != null)
            {
                _context.Genre.Remove(Genre);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProductionCo = await _context.ProductionCo.FindAsync(id);

            if (ProductionCo != null)
            {
                _context.ProductionCo.Remove(ProductionCo);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int?id, string[] selectedGenres)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var movieToUpdate = await _context.Movie
                                .Include(i => i.ProductionCo)
                                .Include(i => i.Developer)
                                .Include(i => i.MovieGenres)
                                .ThenInclude(i => i.Genre)
                                .FirstOrDefaultAsync(s => s.ID == id);

            if (movieToUpdate == null)
            {
                return(NotFound());
            }


            if (await TryUpdateModelAsync <Movie>(
                    movieToUpdate,
                    "Movie",
                    i => i.Title, i => i.Director,
                    i => i.IMDBRatings, i => i.ReleaseDate, i => i.ProductionCoID, i => i.DeveloperID))
            {
                UpdateMovieGenres(_context, selectedGenres, movieToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            //Apelam UpdateMovieGenres pentru a aplica informatiile din checkboxuri la entitatea Movies care //este editata
            UpdateMovieGenres(_context, selectedGenres, movieToUpdate);
            PopulateAssignedGenreData(_context, movieToUpdate);

            return(Page());
        }