Example #1
0
        private AddressContact CreateAddressContact(CreateRegattaViewModel createRegattaViewModel)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.AddressContacts.AddressContact, AddressContact>());
            AddressContact addressContact = Mapper.Map <AddressContact>(createRegattaViewModel.AddressContact);

            using (var context = new AddressContactContext())
            {
                var service = new AddressContactService(context);
                service.Add(addressContact);
            }
            return(addressContact);
        }
Example #2
0
        public ActionResult Create(CreateUserViewModel createUserViewModel)
        {
            if (ModelState.IsValid)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.Users.User, User>());
                var user = Mapper.Map <User>(createUserViewModel.User);

                Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.AddressContacts.AddressContact, AddressContact>());
                var addressContact = Mapper.Map <AddressContact>(createUserViewModel.AddressContact);

                var address = new AddressContactService(new AddressContactContext()).Add(addressContact);
                user.AddressContactId = address.Id;
                new UserService(new UserContext()).Add(user);
                return(RedirectToAction("Index"));
            }

            return(View(createUserViewModel));
        }