//[HttpGet] //[HttpPost] //[ValidateAntiForgeryToken] public ActionResult DescargarArchivo(Guid id) { ArchivoDto _ArchivoDto; FileContentResult _fileContent; using (_dbContext = new NuevoDbContext()) { _ArchivoDto = _dbContext.Archivos.FirstOrDefault(x => x.Id == id); } if (_ArchivoDto == null) { return(HttpNotFound()); } else { try { // Descargamos el ArchivoDto del Servidor. _fileContent = new FileContentResult(_ArchivoDto.DescargarArchivo(), "application/octet-stream"); _fileContent.FileDownloadName = _ArchivoDto.Nombre + "." + _ArchivoDto.Extension; // Actualizamos el nº de descargas en la base de datos. using (_dbContext = new NuevoDbContext()) { _ArchivoDto.Descargas++; _dbContext.Archivos.Attach(_ArchivoDto); _dbContext.Entry(_ArchivoDto).State = EntityState.Modified; _dbContext.SaveChanges(); var usuario = System.Web.HttpContext.Current.User.Identity.Name; var logger = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIA", "Descarga de Archivo", _ArchivoDto.Nombre + '.' + _ArchivoDto.Extension, _ArchivoDto.path, usuario, (int)Session["DenunciaActual"]); _dbContext.Add(logger); _dbContext.SaveChanges(); } return(_fileContent); } catch (Exception ex) { return(HttpNotFound()); } } }