public void UpdateFolder(UserAccount user, int folderId, string newName, int?newParentFolderId) { var folder = GetFolder(user, folderId); if (folder == null) { throw new ArgumentException("Folder not found"); } folder.Name = newName; folder.ParentId = newParentFolderId; ValidateFolderName(folder.Name, folder.ParentId, folderId); dataContext.SaveChanges(); FolderUpdated?.Invoke(this, new SubscriptionFolderUpdatedEventArgs() { User = user, Folder = folder }); }
public void InvokeUpdateFolder(Folder folder) { FolderUpdated?.Invoke(folder); }
public async Task DeleteFolders(UserAccount userAccount, int[] ids, bool recursive, bool deleteFiles) { if (recursive) { if (deleteFiles) { await DeleteSubscriptionFolderFilesJob.Schedule(scheduler, ids, true); } else { DeleteFoldersInternal(userAccount, ids); } } else { // Reparent subscriptions and folders (move them to the parent) var folders = dataContext.SubscriptionFolders.AsQueryable() .Where(x => x.UserId == userAccount.Id) .Where(x => ids.Contains(x.Id)) .ToArray(); foreach (var folder in folders) { dataContext.SubscriptionFolders.AsQueryable() .Where(x => x.ParentId.HasValue && x.ParentId.Value == folder.Id) .ForEach(x => { x.ParentId = folder.ParentId; FolderUpdated?.Invoke(this, new SubscriptionFolderUpdatedEventArgs() { User = userAccount, Folder = x }); }); dataContext.Subscriptions.AsQueryable() .Where(x => x.ParentFolderId.HasValue && x.ParentFolderId.Value == folder.Id) .ForEach(x => { x.ParentFolderId = folder.ParentId; SubscriptionUpdated?.Invoke(this, new SubscriptionUpdatedEventArgs() { User = userAccount, Subscription = x }); }); } // Delete folders var foldersToDelete = dataContext.SubscriptionFolders.AsQueryable() .Where(x => ids.Contains(x.Id)); dataContext.SubscriptionFolders.RemoveRange(foldersToDelete); dataContext.SaveChanges(); FoldersDeleted?.Invoke(this, new SubscriptionFoldersDeletedEventArgs() { User = userAccount, FolderIds = ids }); } }
private void OnFolderUpdated(EventArgs e) { FolderUpdated?.Invoke(this, CurrentDossier); }