public APIResult Friend_CreateFriendGroup(int userID, string groupName, out FriendGroupProxy friendGroup) { friendGroup = null; if (!CheckClient()) { return(null); } APIResult result = new APIResult(); FriendGroup newGroup = null; int errorCode; using (ErrorScope es = new ErrorScope()) { try { result.IsSuccess = FriendBO.Instance.Server_AddFriendGroup(userID, groupName, out newGroup, out errorCode); if (result.IsSuccess == false) { es.CatchError <ErrorInfo>(delegate(ErrorInfo error) { result.AddError(error.TatgetName, error.Message); }); } result.ErrorCode = errorCode; } catch (Exception ex) { result.AddError(ex.Message); result.IsSuccess = false; result.ErrorCode = Consts.ExceptionCode; } friendGroup = ProxyConverter.GetFriendGroupProxy(newGroup); } return(result); }
public List <FriendGroupProxy> Friend_GetFriendGroupsWithFriends(int userID) { if (!CheckClient()) { return(null); } List <FriendGroupProxy> groups = new List <FriendGroupProxy>(); FriendGroupCollection temp = FriendBO.Instance.GetFriendGroups(userID); FriendGroupProxy blackGroup = new FriendGroupProxy(); blackGroup.GroupID = -1; blackGroup.Name = "#black list"; FriendCollection friends = FriendBO.Instance.GetFriendAndBlackList(userID); foreach (BlacklistItem b in friends.Blacklist) { FriendProxy fItem = new FriendProxy(); fItem.GroupID = b.GroupID; fItem.UserID = b.UserID; blackGroup.Friends.Add(fItem); } foreach (FriendGroup fg in temp) { groups.Add(ProxyConverter.GetFriendGroupProxy(fg)); } while (friends.Count > 0) { Friend friend = friends[friends.Count - 1]; FriendProxy fp = ProxyConverter.GetFriendProxy(friend); foreach (FriendGroupProxy proxy in groups) { if (proxy.GroupID == friend.GroupID) { proxy.Friends.Add(fp); } } friends.Remove(friend); } groups.Add(blackGroup); return(groups); }