コード例 #1
0
        public async Task <IActionResult> Create([Bind("PersonId,PersonType,FirstName,MiddleName,LastName")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ZipId,City,Country,ZipCode")] Zip zip)
        {
            if (ModelState.IsValid)
            {
                _context.Add(zip);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(zip));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("EmailId,PersonId,EmailAddress")] Email email)
        {
            if (ModelState.IsValid)
            {
                _context.Add(email);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PersonId"] = new SelectList(_context.PersonMigration, "PersonId", "FirstName", email.PersonId);
            return(View(email));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("AddressId,PersonId,ZipId,StreetName,HouseNumber")] Address address)
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PersonId"] = new SelectList(_context.PersonMigration, "PersonId", "FirstName", address.PersonId);
            ViewData["ZipId"]    = new SelectList(_context.ZipMigration, "ZipId", "City", address.ZipId);
            return(View(address));
        }