コード例 #1
0
ファイル: HomeController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Order(FormCollection form)
        {
            using (var context = new SiteContainer())
            {
                var order = new Order {Date = DateTime.Now};
                TryUpdateModel(order, new[] {"ProductId", "ProductImageSource", "Name", "Email", "Phone", "Description","Size"});
                context.AddToOrder(order);
                context.SaveChanges();

                string defaultMailAddressFrom = ConfigurationManager.AppSettings["feedbackEmailFrom"];
                string defaultMailAddresses = ConfigurationManager.AppSettings["feedbackEmailsTo"];

                var emailFrom = new MailAddress(defaultMailAddressFrom, "Студия Евгения Миллера");

                var emailsTo = defaultMailAddresses
                    .Split(new[] { ";", " ", "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(s => new MailAddress(s))
                    .ToList();

                var result = Helpers.MailHelper.SendTemplate(emailFrom, emailsTo, "Я - Эго. Форма заказа", "FeedbackTemplate.htm", null, true, form["Name"], form["Email"], form["ProductId"], form["Phone"],order.Id);




                return RedirectToAction("Index", "Home", new {id = "gallery"});
            }
        }