public ActionResult AddPanier(List <string> mesCodeISBN) { //add codeISBN via variable locale PanierViewModel panier = new PanierViewModel(mesCodeISBN); return(View(panier)); }
public PanierPage(string nomResto, string addresseResto, List <long> panierpizzId, double prix, int idShop) { BindingContext = new PanierViewModel(idShop, panierpizzId, prix); InitializeComponent(); nomRestaurantLabel.Text = nomResto; addresseRestaurantLabel.Text = addresseResto; prixLabel.Text = "Prix total : " + prix + "€"; }
private void MailCommande(Client client, Commande commande, PanierViewModel panier) { string mailFoodTruck = ConfigurationManager.AppSettings["MailFoodTruck"]; string lesArticlesDansLeMail = ""; foreach (ArticleViewModel article in panier.ArticlesDetailsViewModel) { lesArticlesDansLeMail += "\n" + article.Quantite + " x " + article.Article.Nom + " = " + (article.Quantite * article.Article.PrixTTC).ToString("C2", new CultureInfo("fr-FR")); } CultureInfo cultureinfoFr = new CultureInfo("fr-FR"); string nomClient = client.Nom ?? "non renseigné"; string prenomClient = client.Prenom ?? "non renseigné"; string emailClient = client.Email ?? "non@renseigne"; string corpsDuMailEnCommunClientFoodtruck = $"Nom : {nomClient}\n" + $"Prénom : {prenomClient}\n" + $"Email : {emailClient}\n\n" + $"Articles :{lesArticlesDansLeMail}\n" + $"Total de la commande : {commande.PrixTotalTTC.ToString("C2", cultureinfoFr)}\n"; if (commande.RemiseFidelite > 0) { corpsDuMailEnCommunClientFoodtruck += $"\nRemise fidélité : {commande.RemiseFidelite.ToString("C2", cultureinfoFr)}"; } if (commande.RemiseCommerciale > 0) { corpsDuMailEnCommunClientFoodtruck += $"\nRemise commerciale : {commande.RemiseCommerciale.ToString("C2", cultureinfoFr)}"; } string sujet = $"Nouvelle commande numéro {commande.Id}"; string corpsMail = $"Nouvelle commande {commande.Id}. Merci de la préparer pour le {commande.DateRetrait.ToString("dddd dd MMMM HH:mm")}\n" + corpsDuMailEnCommunClientFoodtruck; Utilitaire.EnvoieMail(mailFoodTruck, sujet, corpsMail); if (client.Id != 0) { string sujetMailClient = $"Nouvelle commande numéro {commande.Id} prise en compte"; string corpsMailClient = $"Bonjour {client.Prenom}\n" + $"Votre dernière commande a bien été prise en compte." + $"\nVous pourrez venir la chercher le {commande.DateRetrait.ToString("dddd dd MMMM")}" + $" à partir de {commande.DateRetrait.ToString("HH:mm").Replace(":", "h")}" + $"\nMerci de votre confiance\n\n" + "voici le récapitulatif : \n" + corpsDuMailEnCommunClientFoodtruck; string objetEvenement = "FoodTruckLyon"; string descriptionEvenement = $"Chercher commande FoodTruckLyon {commande.Id}\n {corpsDuMailEnCommunClientFoodtruck}"; string adresseEvenement = "17 Rue des Gones 69007 Lyon"; DateTime dateDebutEvenement = commande.DateRetrait; DateTime dateFinEvenement = commande.DateRetrait.AddMinutes(int.Parse(ConfigurationManager.AppSettings["PasCreneauxHoraire"])); double lattitudeEvenement = 45.796386; double longitudeEvenement = 5.0379093; MemoryStream pieceJointe = Utilitaire.CreerEvenementCalendrier(objetEvenement, descriptionEvenement, adresseEvenement, dateDebutEvenement, dateFinEvenement, lattitudeEvenement, longitudeEvenement); Utilitaire.EnvoieMail(emailClient, sujetMailClient, corpsMailClient, pieceJointe); } }
protected void RecupererPanierEnBase() { if (Client.Id != 0) { PanierViewModel = new PanierViewModel(new PanierDAL(Client.Id).ListerPanierClient()); } else { PanierViewModel = new PanierViewModel(new PanierProspectDAL(ProspectGuid).ListerPanierProspect()); } }
public ActionResult OrderPaidConfirm() { PanierViewModel cart = (PanierViewModel)Session["Panier"]; ViewBag.TrackingReference = cart.TransactionId; ViewBag.Description = "Transcoder"; ViewBag.TotalCost = cart.GlobalPrice; ViewBag.Currency = "EUR"; Session["Panier"] = null; return(RedirectToAction("Index", "Home")); }
public ActionResult ReprendreArticles(int commandeId, bool viderPanier) { CommandeDAL commandeDAL = new CommandeDAL(); Commande commande = commandeDAL.Detail(commandeId); if (commande != null && commande.ClientId == Client.Id) { List <ArticleViewModel> articles = commandeDAL.Articles(commandeId); if (viderPanier) { new PanierDAL(Client.Id).Supprimer(); PanierViewModel.Initialiser(); ViewBag.Panier = null; //todo } List <Article> articlesKo = new List <Article>(); foreach (var a in articles) { if (!PanierViewModel.Ajouter(a.Article, a.Quantite, Client.Id, ProspectGuid)) { articlesKo.Add(a.Article); } } ViewBag.Panier = PanierViewModel; TempData["ArticlesNonAjoutes"] = articlesKo; if (articlesKo.Count > 0) { string dossierImagesArticles = ConfigurationManager.AppSettings["PathImagesArticles"]; string message = "Les articles suivants ne peuvent pas être repris car ils ne sont plus disponibles :" + "<div class=\"gestionCommandeArticle\">" + "<section class=\"imagesGestionCommande\">"; foreach (Article article in articlesKo) { message += "<div class=\"indexArticle\">" + $"<img src=\"{dossierImagesArticles}/{article.Image}\" alt=\"{article.Nom}\" /> " + $"<p>{article.Nom}</p>" + $"</div>"; } message += "</section>" + "</div>"; TempData["message"] = new Message(message, TypeMessage.Info); // TODO faire plus propre et ailleurs (formatage html propre à la vue) } else { TempData["message"] = new Message($"La reprise des {articles.Count} articles de votre commande s'est correctement réalisée", TypeMessage.Ok); } } RecupererPanierEnBase(); ViewBag.Panier = PanierViewModel; return(RedirectToAction("Index", "Panier")); }
public IActionResult Index() { var items = _shoppingCart.GetCartItems(); _shoppingCart.ShoppingCartItems = items; var panierViewModel = new PanierViewModel { ShoppingCart = _shoppingCart, Total = _shoppingCart.GetShoppingCartTotal(), }; return(View(panierViewModel)); }
public IViewComponentResult Invoke() { var items = _shoppingCart.GetCartItems(); //var items = new List<ShoppingCartItem>() { new ShoppingCartItem(), new ShoppingCartItem() }; _shoppingCart.ShoppingCartItems = items; var panierViewModel = new PanierViewModel { ShoppingCart = _shoppingCart, Total = _shoppingCart.GetShoppingCartTotal() }; return(View(panierViewModel)); }
public PanierViewModel GetPanierViewModel(int userId) { PanierViewModel panier = new PanierViewModel(); panier.ListOfConversions = GetListTaskViewModelByUserId(userId).Where(x => x.IS_PAID == false).ToList(); panier.GlobalPrice = panier.ListOfConversions.Sum(x => x.PRICE); panier.UserId = userId; if (panier.ListOfConversions != null && panier.ListOfConversions.Any()) { panier.TransactionId = panier.ListOfConversions.First().TransactionId; panier.PaypalTransactionId = panier.ListOfConversions.First().PaypalTransactionId; } return(panier); }
protected void InitialiserSession() { RetirerLesDroitsdAcces(); Session["ClientId"] = 0; Client = new Client(); PanierViewModel = new PanierViewModel(); string guid = Guid.NewGuid().ToString(); Session["ProspectGuid"] = guid; HttpCookie cookie = new HttpCookie("Prospect") { Value = guid, Expires = DateTime.Now.AddDays(30) }; Request.Cookies.Add(cookie); }
public ActionResult Ajouter(string nom, string ancre, bool?retourPageArticleIndex) { Article article = new ArticleDAL().Details(nom); if (article != null && article.DansCarte) { PanierViewModel.Ajouter(article, 1, Client.Id, ProspectGuid); ViewBag.Panier = PanierViewModel; } if (retourPageArticleIndex ?? false) { return(Redirect("/Article" + ancre)); } else { return(Redirect(Request.UrlReferrer.AbsolutePath + ancre)); } }
public ActionResult OrderPaypalAuthorized(string token, string PayerID) { PanierViewModel panier = (PanierViewModel)Session["Panier"]; //Récupération des détails de l'appel Express Checkout GetExpressCheckoutDetailsResponse getDetailsResponse = paypalService.SendPayPalGetExpressCheckoutDetailsRequest(token); if (getDetailsResponse == null || getDetailsResponse.ResponseStatus != Core.Transcoder.PayPalMvc.Enums.ResponseType.Success) { string errorMessage = (getDetailsResponse == null) ? "Null Transaction Response" : getDetailsResponse.ErrorToString; Debug.WriteLine("Error initiating PayPal GetExpressCheckoutDetails transaction. Error: " + errorMessage); return(RedirectToAction("Panier", panier)); } //Paiement de la commande DoExpressCheckoutPaymentResponse doCheckoutRepsonse = paypalService.SendPayPalDoExpressCheckoutPaymentRequest(panier, token, PayerID); if (doCheckoutRepsonse == null || doCheckoutRepsonse.ResponseStatus != Core.Transcoder.PayPalMvc.Enums.ResponseType.Success) { if (doCheckoutRepsonse != null && doCheckoutRepsonse.L_ERRORCODE0 == "10486") { Debug.WriteLine("10486 error (bad funding method - typically an invalid credit card)"); return(Redirect(string.Format(Configuration.Current.PayPalRedirectUrl, token))); } string errorMessage = (doCheckoutRepsonse == null) ? "Null Transaction Response" : doCheckoutRepsonse.ErrorToString; Debug.WriteLine("Error initiating PayPal DoExpressCheckoutPayment transaction. Error: " + errorMessage); return(RedirectToAction("Panier", panier)); } if (doCheckoutRepsonse.PaymentStatus == PaymentStatus.Completed) { taskService.SetAllTasksPaidForTransaction(panier.TransactionId); MailUtil.SendMail(Core.Transcoder.Service.Enums.StringManager.PAIEMENT_ACCEPTE, null, panier); return(RedirectToAction("OrderPaidConfirm")); } else { Debug.WriteLine($"Error taking PayPal payment. Error: " + doCheckoutRepsonse.ErrorToString + " - Payment Error: " + doCheckoutRepsonse.PaymentErrorToString); TempData["TransactionResult"] = doCheckoutRepsonse.PAYMENTREQUEST_0_LONGMESSAGE; return(RedirectToAction("Panier", panier)); } }
public static void SendMail(string typeDemande, TASK task = null, PanierViewModel panier = null) { try { SmtpClient client = new SmtpClient(); client.EnableSsl = true; MailMessage mm = task != null?GenerateMailMessage(typeDemande, task) : GenerateMailMessage(typeDemande, null, panier); client.Send(mm); //TRACE Trace = new TRACE { FK_ID_TASK = task.PK_ID_TASK, DATE_TRACE = DateTime.Now, NOM_SERVER = System.Environment.MachineName, FK_ID_SERVER = 1, DESCRIPTION = mm.ToString(), METHOD = "MAIL APRES CONVERSION", TYPE = "INFO" }; //new TRACE_Service().AddTrace(Trace); } catch (Exception e) { TRACE Trace = new TRACE { FK_ID_TASK = task != null ? task.PK_ID_TASK : panier.TransactionId, DATE_TRACE = DateTime.Now, NOM_SERVER = System.Environment.MachineName, FK_ID_SERVER = 1, DESCRIPTION = e.Message, METHOD = "MAIL APRES DEMANDE/CONVERSION", TYPE = "ERROR" }; new TRACE_Service().AddTrace(Trace); } }
private void RecupererPanierProspectPuisSupprimer() { PanierProspectDAL panierProspectDAL = new PanierProspectDAL(ProspectGuid); PanierViewModel panierViewModelSauv = new PanierViewModel(panierProspectDAL.ListerPanierProspect()); if (panierViewModelSauv != null && Client.Id != 0) { PanierDAL panierDal = new PanierDAL(Client.Id); foreach (ArticleViewModel article in (panierViewModelSauv).ArticlesDetailsViewModel) { Panier panier = panierDal.ListerPanierClient().Find(pan => pan.ArticleId == article.Article.Id); if (panier == null) { panierDal.Ajouter(article.Article, article.Quantite); } else { panierDal.ModifierQuantite(article.Article, article.Quantite); } } } panierProspectDAL.Supprimer(); }
public ActionResult ValiderPanier(PanierViewModel model) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (!ModelState.IsValid) { return(View("Panier", model)); } Session["Panier"] = model; string serverURL = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/"); SetExpressCheckoutResponse transactionResponse = paypalService.SendPayPalSetExpressCheckoutRequest(model, serverURL); if (transactionResponse == null || transactionResponse.ResponseStatus != Core.Transcoder.PayPalMvc.Enums.ResponseType.Success) { string errorMessage = (transactionResponse == null) ? "Null Paypal Transaction Response" : transactionResponse.ErrorToString; Debug.WriteLine("Error initiating PayPal SetExpressCheckout transaction. Error: " + errorMessage); return(RedirectToAction("Panier", model)); } FlashMessage.Confirmation(UiStrings.add_conversion_message_cart_validated); return(Redirect(string.Format(Configuration.Current.PayPalRedirectUrl, transactionResponse.TOKEN))); }
public SetExpressCheckoutResponse SendPayPalSetExpressCheckoutRequest(PanierViewModel panier, string serverURL, string userEmail = null) { try { List <ExpressCheckoutItem> expressCheckoutItems = null; if (panier.ListOfConversions != null) { expressCheckoutItems = new List <ExpressCheckoutItem>(); foreach (ListTaskViewModel item in panier.ListOfConversions) { expressCheckoutItems.Add(new ExpressCheckoutItem(1, new decimal(item.PRICE), item.FILE_URL_ACCESS, "")); } } SetExpressCheckoutResponse response = _payPalTransactionRegistrar.SendSetExpressCheckout("EUR", new decimal(panier.GlobalPrice), "Transcoder", panier.PaypalTransactionId, serverURL, expressCheckoutItems, userEmail); return(response); } catch (Exception ex) { Debug.WriteLine(ex.Message, ex); } return(null); }
public DoExpressCheckoutPaymentResponse SendPayPalDoExpressCheckoutPaymentRequest(PanierViewModel panier, string token, string payerId) { try { DoExpressCheckoutPaymentResponse response = _payPalTransactionRegistrar.SendDoExpressCheckoutPayment(token, payerId, "EUR", new decimal(panier.GlobalPrice)); return(response); } catch (Exception ex) { Debug.WriteLine(ex.Message, ex); } return(null); }
public static MailMessage GenerateMailMessage(string typeDemande, TASK task = null, PanierViewModel panier = null) { var message = new MailMessage(); var user = new USER(); if (task != null) { message = new MailMessage("*****@*****.**", task.USER.EMAIL); } else { user = new USER_Service().FindUserByID(panier.UserId); message = new MailMessage("*****@*****.**", user.EMAIL); } message.IsBodyHtml = true; message.BodyEncoding = Encoding.UTF8; switch (typeDemande) { case Enums.StringManager.CONVERSION_TERMINEE: { message.Subject = "Votre conversion n°" + task.PK_ID_TASK; message.Body = "Bonjour " + task.USER.FIRSTNAME + " " + task.USER.LASTNAME + ", <br/> <br/>"; message.Body += "Votre conversion n° " + task.PK_ID_TASK + " a été effectuée. <br/>"; message.Body += "Vous pouvez télécharger votre média en vous rendant sur Transcoder dans la section 'Mes Conversions'<br/>"; message.Body += "Nous vous souhaitons une agréable journée. <br/>"; message.Body += "Cordialement, <br/>"; message.Body += "<p> L'équipe TRANSCODER France </p> <br/>"; break; } case Enums.StringManager.PAIEMENT_ACCEPTE: { message.Subject = "Votre commande n° " + panier.TransactionId; message.Body = "<style>table tr td { border: solid 1px gray;} thead tr { background: #CCC; }</style>"; message.Body = "<p>Bonjour " + user.FIRSTNAME + " " + user.LASTNAME + ",</p> <br/>"; message.Body += "Votre paiement pour la commande n° " + panier.TransactionId + " a été accepté et est en cours de traitement par nos services. <br/><br/>"; message.Body += "Vous recevrez un mail lorsque votre commande sera terminée et prête a être téléchargée. <br/><br/>"; message.Body += "<h3> Récapitulatif de votre commande </h3><hr/>"; message.Body += "<table>"; message.Body += "<thead>"; message.Body += "<tr><td><strong>Nom du fichier</strong></td><td><strong>Format de base</strong></td><td><strong>Format de conversion</strong></td><td><strong>Statut</strong></td><td><strong>Prix</strong></td><tr></thead>"; foreach (var item in panier.ListOfConversions) { message.Body += "<tr>"; message.Body += "<td>" + item.FILE_URL_ACCESS + "</td>"; message.Body += "<td>" + item.FORMAT_BASE + "</td>"; message.Body += "<td>" + item.FORMAT_CONVERT + "</td>"; message.Body += "<td>" + item.STATUS + "</td>"; message.Body += "<td>" + item.PRICE + "</td>"; message.Body += "</tr>"; } message.Body += "</table><hr/><h3 style='color: green'>Montant total de votre commande :<span style='float:right;' >" + panier.GlobalPrice + "€</span></h3>"; message.Body += "Nous vous souhaitons une agréable journée. <br/>"; message.Body += "Cordialement, <br/>"; message.Body += "<p> L'équipe TRANSCODER France </p> <br/>"; break; } default: { break; } } return(message); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); ActionNom = RouteData.Values["action"].ToString(); ControllerNom = RouteData.Values["controller"].ToString(); MettrelUrlEnSession(); if (Session["ClientId"] == null || (int)Session["ClientId"] == 0) { HttpCookie cookie = Request.Cookies.Get("GuidClient"); if (cookie != null && (Client = new ClientDAL().ConnexionCookies(cookie.Value)) != null) { ViewBag.Client = Client; Session["ClientId"] = Client.Id; PanierViewModel = new PanierViewModel(); //Todo effacer AgregerPanierEnBase(); RecupererPanierEnBase(); } else { Session["ClientId"] = 0; ViewBag.Client = Client = new Client(); } } else { ViewBag.Client = Client = new ClientDAL().Details((int)Session["ClientId"]); } new PanierDAL(Client.Id).SupprimerArticlesPasDansCarte(); VisiteDAL.Enregistrer(Client.Id); if (Client.Id != 0) { DonnerLesDroitsdAcces(); PanierViewModel = new PanierViewModel(new PanierDAL(Client.Id).ListerPanierClient()); } else { RetirerLesDroitsdAcces(); if (Session["ProspectGuid"] != null) { ProspectGuid = Session["ProspectGuid"].ToString(); } else { HttpCookie cookie = Request.Cookies.Get("Prospect"); if (cookie != null) { Session["ProspectGuid"] = ProspectGuid = cookie.Value; List <PanierProspect> paniers = new PanierProspectDAL(ProspectGuid).ListerPanierProspect(); if (paniers.Count > 0) { RecupererPanierEnBase(); } } else { string guid = Guid.NewGuid().ToString(); Session["ProspectGuid"] = ProspectGuid = guid; cookie = new HttpCookie("Prospect") { Value = guid, Expires = DateTime.Now.AddDays(30) }; Response.Cookies.Add(cookie); } } new PanierProspectDAL(ProspectGuid).SupprimerArticlesPasDansCarte(); PanierViewModel = new PanierViewModel(new PanierProspectDAL(ProspectGuid).ListerPanierProspect()); } PanierViewModel.Trier(); ViewBag.Panier = PanierViewModel; if (Client.AdminArticle || Client.AdminCommande || Client.AdminClient || Client.AdminPlanning) { ViewBag.MenuAdmin = true; } if (Client.AdminArticle) { ViewBag.AdminArticle = true; } }