public async Task DeleteNotifications( XCollection<Notification> notifications, CancellationToken cancellationToken ) { var exits = await RefreshNotifications( cancellationToken ); var newcollection = new XCollection<Notification>(); foreach (var notification in exits) { if (notifications.All( x => x.NotifiedPerson != notification.NotifiedPerson )) { newcollection.Add( notification ); } } var authors = new List<string>(); foreach (var notification in newcollection) { if (!string.IsNullOrEmpty( notification.NotifiedPerson )) { authors.Add( notification.NotifiedPerson ); } } string authorsString = string.Join( "||", authors ); XCollection<Notification> result; Dictionary<string, object> parameters; if( string.IsNullOrEmpty( authorsString ) ) { if( exits.Count > 0 ) { for (int i = notifications.Count - 1; i >= 0; i--) { var notif = exits.FirstOrDefault(x => x.NotifiedPerson == notifications[i].NotifiedPerson); if (notif != null) exits.Remove(notif); } string newAuthorsString = string.Join("||", exits); parameters = new Dictionary<string, object> { { "update_subscr", newAuthorsString } }; result = (await _client.Subscriptions( parameters, cancellationToken )).Notifications; //parameters = new Dictionary<string, object> //{ // { "del_subscr", exits[0].NotifiedPerson } //}; //result = ( await _client.Subscriptions( parameters, cancellationToken ) ).Notifications; } else { result = new XCollection<Notification>(); } } else { parameters = new Dictionary<string, object> { { "update_subscr", authorsString } }; result = (await _client.Subscriptions( parameters, cancellationToken )).Notifications; } UpdateNotificationList( result, cancellationToken ); }