Example #1
0
        public FileResult GetFile(int id)
        {
            var file = FileService.Get(id);

            byte[] mas        = file.Data;
            string file_type  = "text/plain";
            var    extensions = ExtensionService.GetAll().ToList();
            string file_name  = file.Name + "." + extensions?.FirstOrDefault(e => e.Id == file.ExtensionId)?.ExtensionName;

            return(File(mas, file_type, file_name));
        }
Example #2
0
        public ActionResult Index()
        {
            var user = UserService.GetAll().FirstOrDefault(u => u.Login == Name);

            IEnumerable <BllFile> files = user?.Files;

            if (files == null)
            {
                return(View());
            }
            List <BllFile> viewFiles  = new List <BllFile>();
            var            extensions = ExtensionService.GetAll().ToList();

            foreach (var fileEntity in files)
            {
                fileEntity.Extension = extensions.FirstOrDefault(e => e.Id == fileEntity.ExtensionId);
                viewFiles.Add(fileEntity);
            }
            //ViewBag.Files = viewFiles;
            ViewBag.User = Name;
            return(View(viewFiles.ToList()));
        }