public virtual ActionResult ContactUs(FormCollection formCollection)
        {
            var contact = new Contact();

            TryUpdateModel(contact, formCollection);

            contact.Description = formCollection["Descript"];
            contact.Telephone = formCollection["Telephone"];
            contact.EMail = formCollection["EMail"];
            contact.Subject = formCollection["Subject"];
            contact.AddedDate = DateTime.Now;
            contact.Active = true;

            hopeLingerieEntities.Contacts.AddObject(contact);
            hopeLingerieEntities.SaveChanges();

            Mail mail = hopeLingerieEntities.Mails.SingleOrDefault(a => a.Code == "CONTACTUS");
            if (mail != null)
                MailService.Send(mail.From, "*****@*****.**", mail.Subject, mail.Body);

            return View("Enviado");
        }
Esempio n. 2
0
        public virtual ActionResult ContactUs(FormCollection formCollection)
        {
            var contact = new Contact();

            TryUpdateModel(contact, formCollection);

            contact.NewsLetter = (formCollection["NewsLetter"] != "N");
            contact.Description = formCollection["Descript"];
            contact.AddedDate = DateTime.Now;
            hopeLingerieEntities.Contacts.AddObject(contact);

            if (contact.NewsLetter)
            {
                var newsLetter = new NewsLetter();
                newsLetter.Email = contact.EMail;
                newsLetter.Name = contact.Name;
                newsLetter.AddedDate = DateTime.Now;
                hopeLingerieEntities.NewsLetters.AddObject(newsLetter);
            }

            hopeLingerieEntities.SaveChanges();

            return View("../Home/Index");
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContacts(Contact contact)
 {
     base.AddObject("Contacts", contact);
 }
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="contactId">Initial value of the ContactId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="eMail">Initial value of the EMail property.</param>
 /// <param name="newsLetter">Initial value of the NewsLetter property.</param>
 /// <param name="fromFranchise">Initial value of the FromFranchise property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 /// <param name="addedDate">Initial value of the AddedDate property.</param>
 public static Contact CreateContact(global::System.Int32 contactId, global::System.String name, global::System.String eMail, global::System.Boolean newsLetter, global::System.Boolean fromFranchise, global::System.Boolean active, global::System.DateTime addedDate)
 {
     Contact contact = new Contact();
     contact.ContactId = contactId;
     contact.Name = name;
     contact.EMail = eMail;
     contact.NewsLetter = newsLetter;
     contact.FromFranchise = fromFranchise;
     contact.Active = active;
     contact.AddedDate = addedDate;
     return contact;
 }