Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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());
        }