Example #1
0
        /// <summary>
        /// Takes an prepopulated IDataReader and creates an array of AskAFriendResponses
        /// </summary>
        public static List<AskAFriendResponse> PopulateObject(IDataReader dr)
        {
            ColumnFieldList list = new ColumnFieldList(dr);

            List<AskAFriendResponse> arr = new List<AskAFriendResponse>();

            AskAFriendResponse obj;

            while (dr.Read())
            {
                obj = new AskAFriendResponse();
                if (list.IsColumnPresent("AskAFriendResponseID")) { obj._askAFriendResponseID = (int)dr["AskAFriendResponseID"]; }
                if (list.IsColumnPresent("AskAFriendID")) { obj._askAFriendID = (int)dr["AskAFriendID"]; }
                if (list.IsColumnPresent("MemberID")) { obj._memberID = (int)dr["MemberID"]; }
                if (list.IsColumnPresent("Result")) { obj._result = (int)dr["Result"]; }

                arr.Add(obj);
            }

            dr.Close();

            return arr;
        }
    private void AAFResponse(int QuestionResponseValue)
    {
        AskAFriend AAF = CurrentAskAFriend;

        if (AAF != null)
        {
            //bool IsAllowed = AskAFriend.IsVoteValueAllowed(AAF, QuestionResponseValue);
            bool IsAllowed = true;
            // only add the vote if a valid response was sent to the server
            if (IsAllowed)
            {
                AskAFriendResponse AAFResponse = new AskAFriendResponse();

                AAFResponse.AskAFriendID = AAF.AskAFriendID;

                Member me = (Member)Session["Member"];

                if (me != null)
                {
                    AAFResponse.MemberID = me.MemberID;
                }

                AAFResponse.Result = QuestionResponseValue;

                AAFResponse.Save();

                AAF.TotalVotes++;
                AAF.Save();
            }
        }
    }