Beispiel #1
0
        private async Task <IActionResult> ObterVisaoAcademicoPorId(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var academico = await academicoDAL.ObterAcademicoPorId((long)id);

            if (academico == null)
            {
                return(NotFound());
            }
            return(View(academico));
        }
Beispiel #2
0
        public async Task <FileResult> DownloadFoto(long id)
        {
            Academico academico = await academicoDAL.ObterAcademicoPorId(id);

            string     nomeArquivo = "Foto" + academico.AcademicoID.ToString().Trim() + ".jpg";
            FileStream fileStream  = new FileStream(System.IO.Path.Combine(_env.WebRootPath, nomeArquivo), FileMode.Create, FileAccess.Write);

            fileStream.Write(academico.Foto, 0, academico.Foto.Length);
            fileStream.Close();

            IFileProvider provider   = new PhysicalFileProvider(_env.WebRootPath);
            IFileInfo     fileInfo   = provider.GetFileInfo(nomeArquivo);
            var           readStream = fileInfo.CreateReadStream();

            return(File(readStream, academico.FotoMimeType, nomeArquivo));
        }