public ActionResult General(Guid id) { using (var db = ApplicationDbContext.Create()) { var logger = LogManager.GetLogger("FileController"); var file = GetFile(id, db); logger.Debug("Got file"); EnsureUserIsAllowed(file.CatalogRecord, db); logger.Debug("User is allowed"); var model = new FileViewModel(file) as FileViewModel; model.TermsOfUse = file.CatalogRecord.Organization.TermsOfService; model.IsUserCurator = file.CatalogRecord.Curators.Any(x => x.UserName == User.Identity.Name); model.IsUserApprover = file.CatalogRecord.Approvers.Any(x => x.UserName == User.Identity.Name) || OrganizationHelper.DoesUserHaveRight(db, User, file.CatalogRecord.Organization.Id, Right.CanApprove); var user = db.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault(); model.IsUserAdmin = user.IsAdministrator; string lowerExtension = Path.GetExtension(file.Name).ToLower(); string[] autoDetectedFileTypes = { ".dta", ".sav", ".rdata", ".csv", ".do", ".r", ".sps" }; model.IsFileTypeAutoDetected = autoDetectedFileTypes.Contains(lowerExtension); model.HasAllDataTasks = TaskHelpers.FileHasAllDataTasks(file, file.CatalogRecord, db); model.HasAllCodeTasks = TaskHelpers.FileHasAllCodeTasks(file, file.CatalogRecord, db); logger.Debug("Mapped"); logger.Debug($"Record Status: {model.File.CatalogRecord.Status}"); logger.Debug($"IsCurator: {model.IsUserCurator}"); logger.Debug($"IsApprover: {model.IsUserApprover}"); logger.Debug($"IsReadOnly: {model.IsReadOnly}"); logger.Debug($"Persistent link: {model.File.PersistentLink}"); return(View(model)); } }