Example #1
0
 public ActionResult Create(ContactCreationViewModel contactInfo)
 {
     try
     {
         int     artistId = GetArtistId();
         Contact contact  = contactInfo.Contact;
         Address address  = contactInfo.Address;
         Email   email    = contactInfo.Email;
         AddEmail(email);
         AddAddress(address);
         var emailFromDb   = context.Emails.FirstOrDefault(e => e.EmailAddress == contactInfo.Email.EmailAddress);
         var addressFromDb = context.Addresses.FirstOrDefault(a => a.AddressLine1 == contactInfo.Address.AddressLine1 && a.AddressLine2 == contactInfo.Address.AddressLine2 && a.City == contactInfo.Address.City && a.State == contactInfo.Address.State && a.ZipCode == contactInfo.Address.ZipCode);
         contact.EmailId   = emailFromDb.EmailId;
         contact.AddressId = addressFromDb.AddressId;
         contact.ArtistId  = artistId;
         context.Contacts.Add(contact);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(View());
     }
 }
Example #2
0
        public ActionResult Create()
        {
            ContactCreationViewModel contactInfo = new ContactCreationViewModel();

            return(View(contactInfo));
        }