Exemple #1
0
        public ActionResult Download(Guid id)
        {
            var classRepository = new ClassRepository(_context);
            var file            = classRepository.GetFile(id);

            var classAvailable = classRepository.CheckClassAvailability(file.Class.Id, _loggedUser?.Id);

            if (classAvailable)
            {
                classRepository.SaveAccess(file, _loggedUser);
                return(File(Url.Content("~/" + Parameter.FILE_STORAGE + "/" + file.Class.Id + "/" + file.PhysicalPath),
                            "application/octet-stream", file.PhysicalPath));
            }

            TempData["MessageType"]  = "error";
            TempData["MessageTitle"] = Resource.SupportMaterialDownloadToastrTitle;
            TempData["Message"]      = Resource.WithoutPermissionDownloadToastrMessage;
            return(RedirectToAction("Index", "Home"));
        }