public RemoveResponseModel Remove(ulong id) { if (!EntityStorage.Select <TEntity>().Any(c => c.Id == id)) { return(RemoveResponseModel.NotExisting(id, typeof(TEntity).Name)); } try { EntityStorage.Remove <TEntity>(id); } catch (Exception e) { return(RemoveResponseModel.Exceptional(e)); } return(RemoveResponseModel.Successful()); }
public async Task <JsonResult> Remove(IEnumerable <string> targets) { RemoveResponseModel answer = new RemoveResponseModel(); foreach (string item in targets) { FullPath fullPath = ParsePath(item); RemoveThumbs(fullPath); if (fullPath.Directory != null) { System.IO.Directory.Delete(fullPath.Directory.FullName, true); } else { System.IO.File.Delete(fullPath.File.FullName); } answer.Removed.Add(item); } return(await Json(answer)); }
public async Task <JsonResult> RemoveAsync(IEnumerable <FullPath> paths) { var response = new RemoveResponseModel(); foreach (var path in paths) { await RemoveThumbs(path); if (path.IsDirectory) { Directory.Delete(path.Directory.FullName, true); } else { File.Delete(path.File.FullName); } response.Removed.Add(path.HashedTarget); } return(await Json(response)); }
public async Task <JsonResult> RemoveAsync(IEnumerable <FullPath> paths) { var response = new RemoveResponseModel(); foreach (FullPath path in paths) { await RemoveThumbsAsync(path); if (path.IsDirectory && await path.Directory.ExistsAsync) { await AzureStorageAPI.DeleteDirectoryAsync(path.Directory.FullName); } else if (await path.File.ExistsAsync) { await AzureStorageAPI.DeleteFileAsync(path.File.FullName); } response.Removed.Add(path.HashedTarget); } return(await Json(response)); }