Ejemplo n.º 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(Salle).State = EntityState.Modified;

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


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

            try
            {
                if (AnneeUniversitaire.AnneeCourante == true)
                {
                    foreach (var annee in _context.AnneeUniversitaires)
                    {
                        if (annee.ID != AnneeUniversitaire.ID)
                        {
                            annee.AnneeCourante = false;
                        }
                    }
                }
                else
                {
                    AnneeUniversitaire.AnneeCourante = true;

                    statusmsg = "Veuillez choisir une autre année courante";
                    return(Page());
                }


                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AnneeUniversitaireExists(AnneeUniversitaire.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }