public static void SendEmailFullPerson(PersonFull person) { MailMessage mailMessage = new MailMessage(fromMailAddres, toMailAddres); mailMessage.Subject = "Post Report"; mailMessage.Body = person.ToString(); SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(mailMessage); }
public ActionResult Index(FormCollection collection) { try { PersonFull person = new PersonFull(); // Get base or full person var search = collection["Email"]; var searchResult = DAL.API_Traffic.GetDataFromApi(search); if (searchResult != null) { JArray token = (JArray)searchResult; foreach (var item in token) { string personString = JsonConvert.SerializeObject(item); person = JsonConvert.DeserializeObject <PersonFull>(personString); } } person.Email = collection["Email"]; person.FirstName = collection["FirstName"]; person.LastName = collection["LastName"]; // if full person if (!string.IsNullOrWhiteSpace(person.FirstName) && !string.IsNullOrWhiteSpace(person.WebSite)) { DAL.DatabaseTraffic.SaveFullPerson(person); DAL.MailTraffic.SendEmailFullPerson(person); } else { DAL.DatabaseTraffic.SaveBasePerson(person); DAL.MailTraffic.SendEmailBasePerson(person); } return(View("ThankYou")); } catch (Exception) { return(View()); } }
public static void SaveFullPerson(PersonFull person) { if (person != null) { SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sproc_InsertFullPerson"; command.Parameters.AddWithValue("@FirstName", person.FirstName); command.Parameters.AddWithValue("@LastName", person.LastName); command.Parameters.AddWithValue("@Email", person.Email); command.Parameters.AddWithValue("@Street", person.Address.Street); command.Parameters.AddWithValue("@Suite", person.Address.Suite); command.Parameters.AddWithValue("@City", person.Address.City); command.Parameters.AddWithValue("@ZipCode", person.Address.ZipCode); command.Parameters.AddWithValue("@Website", person.WebSite); command.Parameters.AddWithValue("@Phone", person.Phone); SaveToDb(command); } }
public PersonLite(PersonFull fullPerson) { //copy from fullPerson's properties or whatever }
public void Update(PersonFull person) { }