Ejemplo n.º 1
0
        public int AddAddressGetId(CreateSupporterViewModel viewModel)
        {
            Address newAddress = new Address()
            {
                ContactPerson = viewModel.FullName,
                StreetAddress = viewModel.StreetAddress,
                City          = viewModel.City,
                State         = viewModel.State,
                Zipcode       = viewModel.Zipcode
            };

            db.Addresses.Add(newAddress);
            db.SaveChanges();
            return(newAddress.AddressId);
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "FullName,StreetAddress,City,State,Zipcode")] CreateSupporterViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                var user   = db.Users.Where(c => c.Id == userId).First();
                user.UserRole = "Supporter";
                Supporter supporter = new Supporter()
                {
                    FullName         = viewModel.FullName,
                    Email            = user.Email,
                    SupporterAddress = AddAddressGetId(viewModel),
                    UserId           = userId
                };

                db.Supporters.Add(supporter);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        // GET: Supporters/Create
        public ActionResult Create()
        {
            CreateSupporterViewModel viewModel = new CreateSupporterViewModel();

            return(View(viewModel));
        }