Example #1
0
        public ActionResult Annuler(int commandeId)
        {
            CommandeDAL commandeDAL = new CommandeDAL();
            Commande    commande    = commandeDAL.Detail(commandeId);

            if (commande != null && (commande.ClientId == Client.Id || AdminCommande))
            {
                commandeDAL.Annuler(commandeId);
            }
            return(Redirect(UrlCourante()));
        }
        public ActionResult AnnulerCommande(int commandeId)
        {
            CommandeDAL commandeDAL = new CommandeDAL();
            Commande    commande    = commandeDAL.Detail(commandeId);

            if (commande != null && commande.ClientId == Client.Id)
            {
                commandeDAL.Annuler(commandeId);
            }
            return(RedirectToAction("Commandes", "Compte"));
        }
Example #3
0
 public ActionResult PendantFermetures(int id)
 {
     if (AdminCommande && id == 0)
     {
         CommandeDAL     commandeDAL            = new CommandeDAL();
         List <Commande> commandes              = commandeDAL.CommandesPendantFermetures();
         List <int>      commandesIdMailInconnu = new List <int>();
         foreach (Commande commande in commandes)
         {
             int commandeId = commande.Id;
             commandeDAL.Annuler(commandeId);
             int clientId = commande.ClientId;
             if (clientId != 0)
             {
                 Client client       = new ClientDAL().Details(clientId);
                 string objetMail    = $"Problème commande {commandeId} : Fermeture de votre foodtruck";
                 string corpsMessage = $"Bonjour {client.Prenom}\n\n" +
                                       $"Vous avez passé la commande numéro {commandeId} pour le {commande.DateRetrait.ToString("dddd dd MMMM yyyy à HH:mm").Replace(":", "h")} et nous vous en remercions.\n\n" +
                                       $"Malheureusement nous ne sommes plus ouvert pendant votre horaire de retrait et nous avons été contraint de l'annuler.\n\n" +
                                       $"Nous vous invitons à choisir un autre créneau de retrait (vous pouvez dupliquer votre commande annulée dans votre espace client).\n\n" +
                                       $"Nous vous prions de nous excuser pour la gène occasionnée.\n\n" +
                                       $"Bien cordialement\n" +
                                       $"Votre équipe Foodtrucklyon";
                 string adresseMailClient = client.Email;
                 Utilitaire.EnvoieMail(adresseMailClient, objetMail, corpsMessage);
             }
             else
             {
                 commandesIdMailInconnu.Add(commandeId);
             }
         }
         string message = $"Les {commandes.Count} commande(s) ont bien été annulées et les clients ont reçu un mail";
         if (commandesIdMailInconnu.Count != 0)
         {
             message += "\nAttention :\nLes clients des commandes qui suivent n'ont pas pu être prévenus car ils n'ont pas rensigné les adresses mail :\n";
             foreach (int commandeId in commandesIdMailInconnu)
             {
                 message += $"-{commandeId}-  ";
             }
         }
         TempData["message"] = new Message(message, TypeMessage.Ok);
         return(RedirectToAction(ActionNom));
     }
     else
     {
         return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
     }
 }