Пример #1
0
 public async Task <IActionResult> Edit(Evaluation evaluation)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (!await isOwnerAsync(evaluation))
             {
                 return(Unauthorized());
             }
             _context.Update(evaluation);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!EvaluationExists(evaluation.EvaluationId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(evaluation));
 }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("EvaluationID,Prénom,Nom,TypeReservation,Courriel,DateVisite,QualitéRepas,QualitéService,Commentaires")] Evaluation evaluation)
        {
            if (id != evaluation.EvaluationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(evaluation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EvaluationExists(evaluation.EvaluationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(IndexUtilisateurConnecte)));
            }
            return(View("Index", evaluation));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("PromotionID,TypePromotion,TauxApplicable,Description,DateDébut,DateFin")] Promotion promotion)
        {
            if (id != promotion.PromotionID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(promotion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PromotionExists(promotion.PromotionID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(IndexAdministrateur)));
            }
            return(View(promotion));
        }
        public async Task <IActionResult> Edit([FromForm] Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                var roles = await _userManager.GetRolesAsync(user);

                try
                {
                    if (!await isOwnerAsync(reservation))
                    {
                        return(Unauthorized());
                    }
                    if (!roles.Contains("Administrateur"))
                    {
                        reservation.active = false;
                    }
                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.ReservationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }
Пример #5
0
 public async Task <IActionResult> Edit(Promotion promotion)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(promotion);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!PromotionExists(promotion.PromotionId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(promotion));
 }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("ReservationID,Prénom,Nom,TypeReservation,Courriel,DateHeure,Téléphone,nbPersonnes,StatutReservation")] Reservation reservation)
        {
            if (id != reservation.ReservationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.ReservationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                if ((await _authServ.AuthorizeAsync(User, "AdministrateurSeulement")).Succeeded)
                {
                    return(RedirectToAction(nameof(IndexAdministrateur)));
                }
                else
                {
                    return(RedirectToAction(nameof(IndexUtilisateurConnecte)));
                }
            }
            return(View(reservation));
        }