public async Task <IActionResult> Edit(int id, [Bind("Id,SexId,GenderId,PersonalLyfeJoyId,JobPosition,JobPlace,JobSatisfactionId,ReligionId,Birthday,AttitudeToLife,Credo,Character,TemperamentId,ApplicationUserId")] UserPersonalState userPersonalState) { if (id != userPersonalState.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userPersonalState); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserPersonalStateExists(userPersonalState.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "GenderName", userPersonalState.GenderId); ViewData["JobSatisfactionId"] = new SelectList(_context.JobSatisfactions, "Id", "JobSatisfactionText", userPersonalState.JobSatisfactionId); ViewData["PersonalLyfeJoyId"] = new SelectList(_context.PersonalLyfeJoys, "Id", "LifeJoyExpl", userPersonalState.PersonalLyfeJoyId); ViewData["ReligionId"] = new SelectList(_context.Religions, "Id", "ReligionType", userPersonalState.ReligionId); ViewData["SexId"] = new SelectList(_context.Sexes, "Id", "SexName", userPersonalState.SexId); ViewData["TemperamentId"] = new SelectList(_context.Temperaments, "Id", "TemperamentName", userPersonalState.TemperamentId); return(View(userPersonalState)); }
public async Task <IActionResult> Create([Bind("Id,SexId,GenderId,PersonalLyfeJoyId,JobPosition,JobPlace,JobSatisfactionId,ReligionId,Birthday,AttitudeToLife,Credo,Character,TemperamentId,ApplicationUserId")] UserPersonalState userPersonalState) { if (ModelState.IsValid) { _context.Add(userPersonalState); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "GenderName", userPersonalState.GenderId); ViewData["JobSatisfactionId"] = new SelectList(_context.JobSatisfactions, "Id", "JobSatisfactionText", userPersonalState.JobSatisfactionId); ViewData["PersonalLyfeJoyId"] = new SelectList(_context.PersonalLyfeJoys, "Id", "LifeJoyExpl", userPersonalState.PersonalLyfeJoyId); ViewData["ReligionId"] = new SelectList(_context.Religions, "Id", "ReligionType", userPersonalState.ReligionId); ViewData["SexId"] = new SelectList(_context.Sexes, "Id", "SexName", userPersonalState.SexId); ViewData["TemperamentId"] = new SelectList(_context.Temperaments, "Id", "TemperamentName", userPersonalState.TemperamentId); return(View(userPersonalState)); }