public async Task <IActionResult> PutZip([FromRoute] int id, [FromBody] Zip zip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != zip.ZipId) { return(BadRequest()); } _context.Entry(zip).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ZipExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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)); }
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)); }
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)); }
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)); }