コード例 #1
0
        public void AddUserActionsToLikes(string userAction)
        {
            List <UserAction> listUserActions = Ratings.Where(s => s.Action.Equals(userAction)).ToList();

            this.Likes.AddRange(listUserActions);

            foreach (UserAction uA in listUserActions)
            {
                RaterBase rater = Raters.FirstOrDefault(s => s.Id == uA.Rater.Id);

                if (rater != null)
                {
                    rater.Likes.Add(uA.Ratee);
                }
            }
        }
コード例 #2
0
        public void RemoveUserActionsFromLikes(string userAction)
        {
            List <UserAction> listUserActions = Ratings.Where(s => s.Action.Equals(userAction)).ToList();

            for (int index = listUserActions.Count() - 1, count = 0; count < listUserActions.Count() - 1; index--, count++)
            {
                this.Likes.RemoveAt(index);
            }

            for (int index = listUserActions.Count() - 1; index >= 0; index--)
            {
                UserAction uA    = listUserActions[index];
                RaterBase  rater = Raters.FirstOrDefault(s => s.Id == uA.Rater.Id);

                if (rater != null)
                {
                    rater.Likes.RemoveAt(rater.Likes.Count() - 1);
                }
            }
        }