public async Task <RetailContact> GetRetailContactAsync(int id) { using (DataDbContext context = new DataDbContext()) { RetailContact contact = context.RetailContacts.SingleOrDefault(x => x.Id == id); return(contact); } }
public string SubmitRetailContact(RetailContact contact) { repository.AddRetailContactAsync(contact, false); string subject = "New MagnoVault order"; string content = "<p>A new retail contact was submitted:</p><p>" + contact.FirstName + " " + contact.LastName + "</p><p> + " + contact.Title + ", " + contact.OrgName + "(" + contact.OrgType + ": " + contact.OrgWebsite + ")" + "</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); Emailer mailer = new Emailer(); 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 <RetailContact[]> AddRetailContactAsync(RetailContact newContact, bool returnNewList) { using (DataDbContext context = new DataDbContext()) { context.RetailContacts.Add(newContact); context.SaveChanges(); if (returnNewList) { return(await GetRetailContactsAsync()); } else { return(null); } } //using }
public async Task <RetailContact[]> UpdateRetailContactAsync(RetailContact updatedContact, bool returnNewList) { using (DataDbContext context = new DataDbContext()) { var existingContact = context.RetailContacts.SingleOrDefault(x => x.Id == updatedContact.Id); if (existingContact != null) { //existingContact = updatedContact; context.Entry(existingContact).CurrentValues.SetValues(updatedContact); context.SaveChanges(); } if (returnNewList) { return(await GetRetailContactsAsync()); } else { return(null); } } //using }