当前位置: 首页>>代码示例>>C#>>正文


C# User.IsFriend方法代码示例

本文整理汇总了C#中BoxSocial.Internals.User.IsFriend方法的典型用法代码示例。如果您正苦于以下问题:C# User.IsFriend方法的具体用法?C# User.IsFriend怎么用?C# User.IsFriend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoxSocial.Internals.User的用法示例。


在下文中一共展示了User.IsFriend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BirthdayEvent

        public BirthdayEvent(Core core, User owner, User user, int year)
            : base(core)
        {
            this.owner = owner;
            this.user = user;

            if (!user.IsFriend(owner.ItemKey))
            {
                throw new InvalidEventException();
            }

            UnixTime tz = new UnixTime(core, user.UserInfo.TimeZoneCode);

            this.eventId = ~user.Id;
            this.subject = user.TitleNameOwnership + " birthday";
            this.description = string.Empty;
            this.views = 0;
            this.attendeeCount = 0;
            this.ownerKey = new ItemKey(owner.Id, owner.TypeId);
            this.userId = user.Id;
            this.startTimeRaw =  tz.GetUnixTimeStamp(new DateTime(year, user.Profile.DateOfBirth.Month, user.Profile.DateOfBirth.Day, 0, 0, 0));
            this.endTimeRaw = tz.GetUnixTimeStamp(new DateTime(year, user.Profile.DateOfBirth.Month, user.Profile.DateOfBirth.Day, 23, 59, 59));
            this.allDay = true;
            this.invitees = 0;
            this.category = 0;
            this.location = string.Empty;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:27,代码来源:BirthdayEvent.cs

示例2: AccountFriendManage_Add

        void AccountFriendManage_Add(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            // all ok, add as a friend
            long friendId = 0;

            try
            {
                friendId = long.Parse(core.Http.Query["id"]);
            }
            catch
            {
                SetRedirectUri(BuildUri());
                core.Display.ShowMessage("Cannot add friend", "No friend specified to add. Please go back and try again.");
                return;
            }

            // cannot befriend yourself
            if (friendId == LoggedInMember.UserId)
            {
                SetRedirectUri(BuildUri());
                core.Display.ShowMessage("Cannot add friend", "You cannot add yourself as a friend.");
                return;
            }

            // check existing friend-foe status
            DataTable relationsTable = db.Query(string.Format("SELECT relation_type FROM user_relations WHERE relation_me = {0} AND relation_you = {1}",
                LoggedInMember.UserId, friendId));

            for (int i = 0; i < relationsTable.Rows.Count; i++)
            {
                if ((string)relationsTable.Rows[i]["relation_type"] == "FRIEND")
                {
                    core.Display.ShowMessage("Already friend", "You have already added this person as a friend.");
                    return;
                }
                if ((string)relationsTable.Rows[i]["relation_type"] == "BLOCKED")
                {
                    core.Display.ShowMessage("Person Blocked", "You have blocked this person, to add them as a friend you must first unblock them.");
                    return;
                }
            }

            User friendProfile = new User(core, friendId);

            bool isFriend = friendProfile.IsFriend(session.LoggedInMember.ItemKey);

            db.BeginTransaction();
            long relationId = db.UpdateQuery(string.Format("INSERT INTO user_relations (relation_me, relation_you, relation_time_ut, relation_type) VALUES ({0}, {1}, UNIX_TIMESTAMP(), 'FRIEND');",
                LoggedInMember.UserId, friendId));

            //
            // send notifications
            //

            ApplicationEntry ae = core.GetApplication("Profile");

            if (!isFriend)
            {
                ae.SendNotification(core, LoggedInMember, friendProfile, LoggedInMember.ItemKey, LoggedInMember.ItemKey, "_WANTS_FRIENDSHIP", LoggedInMember.Uri, "friend");
            }
            else
            {
                ae.SendNotification(core, LoggedInMember, friendProfile, LoggedInMember.ItemKey, LoggedInMember.ItemKey, "_ACCEPTED_FRIENDSHIP", LoggedInMember.Uri);
            }

            db.UpdateQuery(string.Format("UPDATE user_info ui SET ui.user_friends = ui.user_friends + 1 WHERE ui.user_id = {0};",
                LoggedInMember.UserId));

            SetRedirectUri(BuildUri());
            core.Display.ShowMessage("Added friend", "You have added a friend.");
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:73,代码来源:AccountFriendManage.cs

示例3: Invite

        public void Invite(Core core, User invitee)
        {
            core.LoadUserProfile(userId);
            User user = core.PrimitiveCache[userId];
            // only the person who created the event can invite people to it
            if (core.LoggedInMemberId == userId)
            {
                // we can only invite people friends with us to an event
                if (invitee.IsFriend(user.ItemKey))
                {
                    InsertQuery iQuery = new InsertQuery("event_invites");
                    iQuery.AddField("event_id", EventId);
                    iQuery.AddField("item_id", invitee.Id);
                    iQuery.AddField("item_type_id", invitee.TypeId);
                    iQuery.AddField("inviter_id", userId);
                    iQuery.AddField("invite_date_ut", UnixTime.UnixTimeStamp());
                    iQuery.AddField("invite_accepted", false);
                    iQuery.AddField("invite_status", (byte)EventAttendance.Unknown);

                    long invitationId = db.Query(iQuery);

                    UpdateQuery uQuery = new UpdateQuery("events");
                    uQuery.AddField("event_invitees", new QueryOperation("event_invitees", QueryOperations.Addition, 1));
                    uQuery.AddCondition("event_id", EventId);

                    db.Query(uQuery);

                    core.CallingApplication.SendNotification(core, user, invitee, OwnerKey, ItemKey, "_INVITED_EVENT", Uri, "invite");

                }
                else
                {
                    throw new CouldNotInviteEventException();
                }
            }
            else
            {
                throw new CouldNotInviteEventException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:40,代码来源:Event.cs


注:本文中的BoxSocial.Internals.User.IsFriend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。