Beispiel #1
0
        public IActionResult DeleteUser(int id)
        {
            if (!_auth.Authorise(RolesEnum.Admin, _context)) // Authenticate the user
            {
                return(Redirect("~/Project/Dashboard"));
            }

            // Get the project Id from the session
            var projId = int.Parse(HttpContext.Session.GetString("SelectedProject"));

            // Get the record of the link
            var user = _context.ProjectUsers.First(u => u.UserId == id && u.ProjectId == projId);

            // Remove the user from the project
            _context.Remove(user);

            // Save the changes.
            _context.SaveChanges();

            // Kick back to the page
            return(Redirect($"~/ProjectManagement/DeleteUsersFromProject/{projId}"));
        }