public IActionResult Details(int id) { var asset = _libraryDataService.GetAsset(id); if (asset == null) { return(NotFound()); } var dtoAsset = asset.DtoMap <DetailViewModel>(); dtoAsset.Type = _libraryDataService.GetType(id).ToString().ToLower(); return(Json(dtoAsset)); }
public IActionResult Delete(int id) { var asset = _libraryDataService.GetAsset(id); if (asset == null) { return(NotFound()); } if (asset.ImageUrl != "none") { _imageService.DeleteImage(_appEnvironment.WebRootPath, asset.ImageUrl); } _libraryDataService.RemoveAsset(asset); _libraryDataService.SaveChanges(); return(Ok()); }
public IActionResult DownloadData([FromBody] DownloadFileModel downloadFile) { var asset = _libraryDataService.GetAsset(downloadFile.Id); if (asset == null) { return(NotFound()); } byte[] fileData = _dataFileService.TryGetFile(asset, downloadFile.Type); if (fileData == null) { return(NotFound()); } var fileName = Regex.Replace(asset.Title, @"[^a-zA-z0-9]+", String.Empty) + "." + downloadFile.Type; return(File(fileData, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); }