Exemplo n.º 1
0
        public static void ApplyUserEventsToCache(IEnumerable <UserEvent> userEvents)
        {
            List <int> subscriptionsAdded   = new List <int>();
            List <int> subscriptionsRemoved = new List <int>();

            foreach (UserEvent ue in userEvents)
            {
                switch (ue.eventType)
                {
                case UserEventType.ModSubscribed:
                {
                    subscriptionsAdded.Add(ue.modId);
                }
                break;

                case UserEventType.ModUnsubscribed:
                {
                    subscriptionsRemoved.Add(ue.modId);
                }
                break;
                }
            }

            List <int> subscriptions = CacheClient.LoadAuthenticatedUserSubscriptions();

            subscriptions.RemoveAll(s => subscriptionsRemoved.Contains(s));
            subscriptions.AddRange(subscriptionsAdded);

            CacheClient.SaveAuthenticatedUserSubscriptions(subscriptions);
        }