Example #1
0
        /// <summary>
        /// Determines whether this sender can send message to the specified recipient.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="recipient">The recipient.</param>
        /// <param name="reason">The reason.</param>
        /// <returns>
        /// 	<c>true</c> if this sender can send message to the specified recipient; otherwise, <c>false</c>.
        /// </returns>
        public static bool CanSendMessage(User sender, User recipient, out string reason)
        {
            bool result = true;
            reason = "";

            if (!recipient.IsUserInFriendList(sender.Username) && !IsUserInFavouriteList(recipient.Username, sender.Username))
            {
                switch (recipient.IncomingMessagesRestrictions.MessagesFrom)
                {
                    case Data.IncomingMessagesRestrictions.eMessagesFrom.Men:
                        if (sender._gender != eGender.Male)
                        {
                            result = false;
                            reason = Lang.Trans("The user has restricted incoming messages from users of your gender.");
                            return result;
                        }
                        break;

                    case Data.IncomingMessagesRestrictions.eMessagesFrom.Women:
                        if (sender._gender != eGender.Female)
                        {
                            result = false;
                            reason = Lang.Trans("The user has restricted incoming messages from users of your gender.");
                            return result;
                        }
                        break;

                    //case Data.IncomingMessagesRestrictions.eMessagesFrom.Favorites:
                    //    if (!IsUserInFavouriteList(recipient.Username, sender.Username))
                    //    {
                    //        result = false;
                    //        reason =
                    //            Lang.Trans(
                    //                "The user has restricted incoming messages from users not in their favourite list.");
                    //        return result;
                    //    }
                    //    break;
                }

                if (sender.Age < recipient.IncomingMessagesRestrictions.AgeFrom ||
                    sender.Age > recipient.IncomingMessagesRestrictions.AgeTo)
                {
                    result = false;
                    reason = Lang.Trans("The user has restricted incoming messages from users of your age.");
                    return result;
                }

                if (recipient.IncomingMessagesRestrictions.PhotoRequired)
                {
                    try
                    {
                        sender.GetPrimaryPhoto();
                    }
                    catch (NotFoundException)
                    {
                        result = false;
                        reason = Lang.Trans("The user has restricted incoming messages from users without photo.");
                        return result;
                    }
                }
            }
            return result;
        }
Example #2
0
        public static string GetFormattedString(this string templateStr, User user)
        {
            return templateStr.GetKeyValueFormattedString("%%RECIPIENT%%", user.Name)
                              .GetKeyValueFormattedString("%%CONFIRM_URL%%", String.Format(""))
                              .GetKeyValueFormattedString("%%SENDER%%",user.Name)
                              //.GetKeyValueFormattedString("%%MESSAGE%%","")
                              .GetKeyValueFormattedString("%%USERNAME%%",user.Username)
                              .GetKeyValueFormattedString("%%RECIPIENTNAME%%",user.Name)
                              .GetKeyValueFormattedString("%%PHOTOURL%%",ImageHandler.CreateImageUrl(user.GetPrimaryPhoto().Id,200,200,false,false,true)
                              .GetKeyValueFormattedString("%%AGE%%",user.Age.ToString())
                              .GetKeyValueFormattedString("%%PROFILEURL%%",Config.Urls.Home+"ShowUser_"+user.Username+".aspx")
                              .GetKeyValueFormattedString("%%PHOTOID%%",user.GetPrimaryPhoto().Id.ToString())
                              //.GetKeyValueFormattedString("%%USERSPROFILES%%","")
                              .GetKeyValueFormattedString("%%USER%%",user.Username)
                              .GetKeyValueFormattedString("%%SITETITLE%%","ezFixUp")
                              //.GetKeyValueFormattedString("%%REASON%%","")
                              //.GetKeyValueFormattedString("%%SUBJECT%%","")
                              //.GetKeyValueFormattedString("%%GROUP%%","")
                              //.GetKeyValueFormattedString("%%RECIPIENTUSERNAME%%","")
                              //.GetKeyValueFormattedString("%%AFFILIATE%%","")
                              .GetKeyValueFormattedString("%%DAYSLEFTFORMEMBERSHIP%%",(Subscription.FetchActiveSubscription(user.Username).RenewDate - DateTime.Now).ToString())
                              .GetKeyValueFormattedString("%%NUMBEROFFRIENDS%%",user.FetchFriends().Length.ToString())
                              .GetKeyValueFormattedString("%%MAILBAOXLINK%%",Config.Urls.Home+"/Mailbox.aspx")
                              .GetKeyValueFormattedString("%%FRIENDSLINK%%",Config.Urls.Home+"/FriendsList.aspx")
                              .GetKeyValueFormattedString("%%MATCHMAKERLINK%%",Config.Urls.Home+"/Home_mm.aspx")
                              .GetKeyValueFormattedString("%%FACEBOOKAPPLINK%%",Config.Urls.FacebookHome)
                              .GetKeyValueFormattedString("%%INVITEFRIENDSLINK%%",Config.Urls.Home+"/InviteFriends.aspx")
                              .GetKeyValueFormattedString("%%CREDITBALANCE%%",Config.Urls.Home+"/ManageProfile.aspx?sel=payment")
                              .GetKeyValueFormattedString("%%MATCHMAKINGCOUNT%%",MatchMaking.FetchMatchMakings(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%NEWMESSAGESCOUNT%%",Message.FetchNewMessages(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%TOTALINBOXCOUNT%%",Message.FetchInbox(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%TOTALRECIEVEDGIFTSCOUNT%%", "")
                              .GetKeyValueFormattedString("%%TOTALSENTGIFTSCOUNT%%",""));
                                          
	
        }