public async Task <IActionResult> Create([Bind("PersonId,Name,Surname")] Person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Create([Bind("BugId,Title,Description,IsClosed")] BugCreateViewModel model) { if (ModelState.IsValid) { _context.Add(model); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var ticket = await _context.Tickets.FindAsync(id); _context.Tickets.Remove(ticket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("ProjectID,ProjectName,ManagerID")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } List <BugTrackerUser> Managers = new List <BugTrackerUser>(); foreach (BugTrackerUser user in _context.BugTrackerUsers) { if (rolesManipulator.GetUserRoles(user.BugTrackerUserID).ID == RolesIDs.ManagerID) { Managers.Add(user); } } ViewData["ManagerID"] = new SelectList(Managers, "BugTrackerUserID", "Name"); return(View(project)); }
public async Task <IActionResult> Edit(string id, [Bind("BugTrackerUserID,Name,Age")] BugTrackerUser bugTrackerUser, string role) { if (id != bugTrackerUser.BugTrackerUserID) { return(NotFound()); } if (ModelState.IsValid) { try { Role currentUserRole = rolesManipulator.GetUserRoles(bugTrackerUser.BugTrackerUserID); if (currentUserRole.ID != role) { rolesManipulator.DeleteRoleFromUser(bugTrackerUser.BugTrackerUserID, currentUserRole.ID); rolesManipulator.AssignRoleToUser(bugTrackerUser.BugTrackerUserID, role); } _context.Update(bugTrackerUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BugTrackerUserExists(bugTrackerUser.BugTrackerUserID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bugTrackerUser)); }