public ActionResult OpenEditor(int?id, string code, int?fileID) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } // Checks if the user has access to the project. if (!service.HasAccess(Convert.ToInt32(id))) { throw new Exception("Project is Empty or no access"); } ListFileViewModel model = new ListFileViewModel(); ThemeViewModel themeModel = new ThemeViewModel(); model.AllFiles = service.GetAllFiles(Convert.ToInt32(id)); if (model.AllFiles.Count == 0) { return(RedirectToAction("CreateFile", new { id = id })); } if (fileID == null) { // Redirects to get first file to display. return(RedirectToAction("DisplayFile", new { id = model.AllFiles.First().ID, projectID = id })); } ViewBag.ProjectName = service.GetProjectName(Convert.ToInt32(id)); model.ProjectId = Convert.ToInt32(id); model.Content = code; model.ProjectId = Convert.ToInt32(id); model.FileId = Convert.ToInt32(fileID); model.Filetype = fileService.GetFileTypeName(Convert.ToInt32(fileID)); model.Theme = themeService.CallTheme(); model.Users = service.UserListofSharedProject(Convert.ToInt32(id)); return(View(model)); }