예제 #1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        // Edition du film s'il existe dans la bdd
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

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

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            //Si erreur liée au modèle, le formulaire est réaffiché
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Sinon on ajoute le film
            _context.User.Add(User);
            await _context.SaveChangesAsync();

            //Redirection vers la page Privacy
            return(RedirectToPage("../MovieDisplay"));
        }
예제 #3
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        //Instructions de retour de la page
        public async Task <IActionResult> OnPostAsync()
        {
            //Si erreur liée au modèle, le formulaire est réaffiché
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Sinon on ajoute le film
            _context.Movie.Add(Movie);
            await _context.SaveChangesAsync();

            //Redirection vers la page Index (l'accueil)
            return(RedirectToPage("./Index"));
        }
예제 #4
0
        //Suppression d'un film s'il est dans la bdd
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
예제 #5
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        //Instructions de retour de la page
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            //Si erreur liée au modèle, le formulaire est réaffiché
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            //Sinon on ajoute la commande
            _context.Commande.Add(Commande);
            // On incrémente également de nb de locations du films dans la base de donées Movie
            var query = from m in _context.Movie where m.ID == id select m;

            foreach (Movie m in query)
            {
                m.NbLocation += 1;
            }
            // On sauvegarde ces changements
            await _context.SaveChangesAsync();

            //Redirection vers la page qui indique que la commande a été prise en compte
            return(RedirectToPage("./ValidationCommande"));
        }