// Returns the main site where all projects are displayed. Checks the user identity to know which projects to display for logged in users. public ActionResult Index(int?id) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } ListProjectViewModel listAll = new ListProjectViewModel(); // If there is no id it will display all projects related to user. if (id == null) { ViewBag.Title = "All Projects"; listAll.AllProject = service.GetAllUserProjects(); } // If id is 1 it will only display projects that current user created. else if (id == 1) { ViewBag.Title = "My Projects"; listAll.AllProject = service.GetMyProjects(); } // Otherwise it will display projects that have been shared with the current user. else { ViewBag.Title = "Shared with me"; listAll.AllProject = service.GetSharedProjects(); } return(View(listAll)); }
private ListProjectViewModel GetProjectViewModel(Project project, ListItemModelBase parent) { var projectViewModel = new ListProjectViewModel(project, parent, _dataService, _userRepository); foreach (var task in project.Tasks) { var taskViewModel = GetTaskViewModel(task, projectViewModel); if (taskViewModel != null) { projectViewModel.Children.Add(taskViewModel); } } return(projectViewModel); }