private AddressContact CreateAddressContact(CreateClubsViewModel createClubViewModel) { Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.AddressContacts.AddressContact, AddressContact>()); AddressContact addressContact = Mapper.Map <AddressContact>(createClubViewModel.AddressContact); using (var context = new AddressContactContext()) { var service = new AddressContactService(context); service.Add(addressContact); } return(addressContact); }
public ActionResult Create(CreateClubsViewModel createClubViewModel) { if (ModelState.IsValid) { AddressContact addressContact = CreateAddressContact(createClubViewModel); Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.Clubs.PocoClub, Club>()); Club Clubs = Mapper.Map <Club>(createClubViewModel.Club); Clubs.AddressContactId = addressContact.Id; using (var context = new ClubContext()) { var service = new ClubService(context); service.Create(Clubs); } return(RedirectToAction("Index")); } return(View()); }