public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,IsActive,IsCommitteeAdmin,JoinDate,CommitteeId,Task")] CommitteeProfile committeeProfile) { if (id != committeeProfile.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(committeeProfile); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommitteeProfileExists(committeeProfile.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details", "Committees", new { /* routeValues, for example: */ id = committeeProfile.CommitteeId })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", committeeProfile.ApplicationUserId); ViewData["CommitteeId"] = new SelectList(_context.Committees, "Id", "Name", committeeProfile.CommitteeId); return(View(committeeProfile)); }
public async Task <IActionResult> Create(int?cid, [Bind("Id,ApplicationUserId,IsActive,IsCommitteeAdmin,JoinDate,CommitteeId,Task")] CommitteeProfile committeeProfile) { if (ModelState.IsValid) { committeeProfile.JoinDate = DateTime.Now; _context.Add(committeeProfile); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = committeeProfile.Id })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", committeeProfile.ApplicationUserId); ViewData["CommitteeId"] = new SelectList(_context.Committees.Where(a => a.Id == committeeProfile.CommitteeId), "Id", "Name", cid); return(View(committeeProfile)); }