public ActionResult Details(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.ProjectTask)) { return(RedirectToPermissionDenied()); } // Check if a project task ID was provided if (id == null) { return(RedirectToIndex()); } int projectTaskId = (int)id; // Entry try-catch from here // Make sure any errors are displayed try { // Get the project task data var projectTaskModel = ProjectTaskProcessor.GetProjectTask(projectTaskId); if (projectTaskModel == null) { return(RedirectToIndexIdNotFound(projectTaskId)); } // Convert the model data to non-model data var projectTask = new ProjectTask(projectTaskModel) { // Fill in missing text data ProjectRoleName = ProjectRoleProcessor.GetProjectRole(projectTaskModel.ProjectRoleId)?.Name, StudentUsername = UserProcessor.SelectUserForEnrollment(projectTaskModel.EnrollmentId)?.Username }; // Pass the data to the view return(View(projectTask)); } catch (Exception e) { return(RedirectToIndex(e)); } }
public ActionResult Edit(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.ProjectRole)) { return(RedirectToPermissionDenied()); } // Check if a project role ID was provided if (id == null) { return(RedirectToIndex()); } int projectRoleId = (int)id; // Entry try-catch from here // Make sure any errors are displayed try { // Get the project role data var projectRoleModel = ProjectRoleProcessor.GetProjectRole(projectRoleId); if (projectRoleModel == null) { return(RedirectToIndexIdNotFound(projectRoleId)); } // Convert the model data to non-model data // Pass the data to the view return(View(new ProjectRole(projectRoleModel))); } catch (Exception e) { return(RedirectToIndex(e)); } }