Esempio n. 1
0
        public ActionResult Create(bool prepopulated = false)
        {
            if (HttpContext.Session["homePageModel"] != null && prepopulated)
            {
                //DateTime dateTime = DateTime.UtcNow.Date;
                InstantQuoteViewModel model      = (InstantQuoteViewModel)HttpContext.Session["homePageModel"];
                CreateOrderViewModel  orderModel = new CreateOrderViewModel
                {
                    Cost          = model.Cost,
                    NeedsPrint    = model.NeedsPrint,
                    IsDoubleSided = model.IsDoubleSided,
                    IsMetro       = model.IsMetro,
                    Quantity      = model.Quantity,
                    PrintSize     = model.PrintSize
                };

                return(this.View(orderModel));
            }

            return(this.View());
        }
Esempio n. 2
0
        public async Task <ActionResult> EmailQuote(EmailQuotes model1)
        {
            {
                InstantQuoteViewModel model = (InstantQuoteViewModel)HttpContext.Session["homePageModel1"];



                if (ModelState.IsValid && (model.NeedsPrint == true))
                {
                    var url      = @"\home\index";
                    var linkText = "Click here";
                    var body     = "Hi {6}, </br><p>Here is your quote: </p></br><p>Quantity: {0}</p><p>Metro Area: {1}</p><p>Is printing required: {2}" +
                                   "</p><p>Print Size: {3}</p><p>Double Sided: {4}</p><p>Price: {5}</p></br><p>Thank you for your interest. Please reply to this email to place an order.</p><p>Kind Regards,</p>SG Fast Flyers.";
                    string attach          = Server.MapPath(@"\Content\Documents\SGFastFlyers_Letterbox_Printing_&_Delivery_Details.pdf");
                    string href            = String.Format("<a href='{0}'>{1}</a>", url, linkText);
                    string yourEncodedHtml = "Quote Sent Successfully.<br/>" + href + " to send another one if you like.<br/><p>Have a great day.<p/>";
                    var    html            = new MvcHtmlString(yourEncodedHtml);
                    var    message         = new MailMessage();
                    message.To.Add(new MailAddress(model1.Email));     // replace with valid value
                    message.Bcc.Add(new MailAddress(Config.sgEmail));
                    message.From    = new MailAddress(Config.sgEmail); // replace with valid value
                    message.Subject = "Your Quote";
                    message.Body    = string.Format(body, model.Quantity, (model.IsMetro == true ? Config.Yes : Config.No), (model.NeedsPrint == true ? Config.Yes : Config.No), model.PrintSize,
                                                    (model.IsDoubleSided == true ? Config.Yes : Config.No), model.FormattedCost, model1.FirstName);
                    message.IsBodyHtml = true;
                    message.Attachments.Add(new Attachment(attach));



                    try
                    {
                        using (SmtpClient smtp = new SmtpClient())
                        {
                            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory;
                            await smtp.SendMailAsync(message);
                        }
                        ViewBag.Status = html;
                        ModelState.Clear();
                    }
                    catch (Exception)
                    {
                        ViewBag.Status = "Problem while sending email, Please check details.";
                    }
                }
                if (ModelState.IsValid && (model.NeedsPrint == false))
                {
                    var url      = @"\home\index";
                    var linkText = "Click here";
                    var body     = "Hi {0}, </br><p>Here is your quote: </p></br><p>Quantity: {1}</p><p>Metro Area: {2}</p>" +
                                   "<p>Price: {3}</p></br><p>Thank you for your interest. Please reply to this email to place an order.</p><p>Kind Regards,</p>SG Fast Flyers.";
                    string attach          = Server.MapPath(@"\Content\Documents\SGFastFlyers_Letterbox_Printing_&_Delivery_Details.pdf");
                    string href            = String.Format("<a href='{0}'>{1}</a>", url, linkText);
                    string yourEncodedHtml = "Quote Sent Successfully.<br/>" + href + " to send another one if you like.<br/><p>Have a great day.<p/>";
                    var    html            = new MvcHtmlString(yourEncodedHtml);
                    var    message         = new MailMessage();
                    message.To.Add(new MailAddress(model1.Email));     // replace with valid value
                    message.Bcc.Add(new MailAddress(Config.sgEmail));
                    message.From    = new MailAddress(Config.sgEmail); // replace with valid value
                    message.Subject = "Your Quote";
                    message.Body    = string.Format(body, model1.FirstName, model.Quantity, (model.IsMetro == true ? Config.Yes : Config.No),
                                                    model.FormattedCost);
                    message.IsBodyHtml = true;
                    message.Attachments.Add(new Attachment(attach));


                    try
                    {
                        using (SmtpClient smtp = new SmtpClient())
                        {
                            await smtp.SendMailAsync(message);
                        }
                        ViewBag.Status = html;
                        ModelState.Clear();
                    }
                    catch (Exception)
                    {
                        ViewBag.Status = "Problem while sending email, Please check details.";
                    }
                }
                return(View());
            }
        }