public static void UnLike(SPWeb web, SPUser user, SPListItem listItem) { try { if (listItem["LikedBy"] != null) { var likedBy = new SPFieldUserValueCollection(web, listItem["LikedBy"].ToString()); if (likedBy.Any(f => f.LookupId == user.ID)) { var deleteUser = likedBy.First(f => f.LookupId == user.ID); int likes = likedBy.Distinct().Count(); likedBy.Remove(deleteUser); likes = likes - 1; listItem["LikesCount"] = likes; listItem["LikedBy"] = likedBy; listItem.SystemUpdate(false); } } } catch (Exception e) { Logger.Logger.Unexpected("LikesColumn.UnLike", e.Message); throw e; } }