public async Task<IActionResult> Create([Bind("Id,FirstName,LastName,PublicId,BirthDate,BirthPlace,Attributes")] Person person) { if (ModelState.IsValid) { person.Id = Guid.NewGuid(); _context.Add(person); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(person); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,PollStartDate,PollEndDate,ElectorateListClosingDate,ElectionTypeFk")] Election election) { if (ModelState.IsValid) { election.Id = Guid.NewGuid(); election.Configuration = _context.ElectionType.Single(q => q.Id == election.ElectionTypeFk).DefaultConfiguration; _context.Add(election); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ElectionTypeFk"] = new SelectList(_context.ElectionType, "Id", "Name", election.ElectionTypeFk); return(View(election)); }