public string SubmitPublicContact(PublicContact contact) { repository.AddPublicContactAsync(contact, false); string subject = "New MagnoVault order"; string content = "<p>A new public contact was submitted:</p><p>" + contact.FirstName + " " + contact.LastName + "</p><p>" + contact.City + ", " + contact.State + "</p><p>" + contact.Phone + "</p><p>" + contact.Email + "</p><p>Prefers: " + contact.BestMethod + "</p><p>" + contact.Message + "</p>"; SendEmail(subject, content); return "Thank you for your interest in MagnoVault. Your request has been submitted, and we will be pleased to get back to you shortly!"; }
public async Task <PublicContact> GetPublicContactAsync(int id) { using (DataDbContext context = new DataDbContext()) { PublicContact contact = context.PublicContacts.SingleOrDefault(x => x.Id == id); return(contact); } }
public async Task <PublicContact[]> AddPublicContactAsync(PublicContact newContact, bool returnNewList) { using (DataDbContext context = new DataDbContext()) { context.PublicContacts.Add(newContact); context.SaveChanges(); if (returnNewList) { return(await GetPublicContactsAsync()); } else { return(null); } } //using }
public async Task <PublicContact[]> UpdatePublicContactAsync(PublicContact updatedContact, bool returnNewList) { using (DataDbContext context = new DataDbContext()) { var existingContact = context.PublicContacts.SingleOrDefault(x => x.Id == updatedContact.Id); if (existingContact != null) { //existingContact = updatedContact; context.Entry(existingContact).CurrentValues.SetValues(updatedContact); context.SaveChanges(); } if (returnNewList) { return(await GetPublicContactsAsync()); } else { return(null); } } //using }