public async Task <ActionResult> Create([Bind(Include = "Id,Address1,CIty,State,ZipCode")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(address));
        }
Exemple #2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,DOB,Email,AddressID")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.AddressID = new SelectList(db.Addresses, "Id", "Address1", user.AddressID);
            return(View(user));
        }