public ActionResult Download(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserFile file = repo.GetFileById(id.Value); if (file == null) { return(HttpNotFound()); } return(File(file.Content, file.MimeType, file.GetFileName())); }
private FileViewModel MapFileToFileViewModel(UserFile file) { if (file == null) { return(null); } return(new FileViewModel() { ID = file.ID, Title = file.Title, Description = file.Description, DepartmentID = file.Department.ID, DepartmentName = file.Department.Name, FileName = file.GetFileName(), AllowEdit = file.Department.Manager.UserName == User.Identity.Name //AllowEdit = User.IsInRole("Boss")//repo.GetManagedDepartmentsByUserName(User.Identity.Name).Contains(file.Department) }); }