Exemple #1
0
        public static MsCrmResultObject GetForumInfo(Guid forumId, Guid portalUserId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
	                                    f.new_forumId AS Id
	                                    ,f.new_name AS Name
	                                    ,f.new_parentforumId AS ParentForumId
	                                    ,f.new_parentforumIdName AS ParentForumIdName
	                                    ,f.CreatedOn
                                    FROM
	                                    new_forum AS f (NOLOCK)
                                    WHERE
	                                    f.new_forumId='{0}'
                                    AND
	                                    f.statecode=0
                                    AND
	                                    f.statuscode=1 --Active"    ;
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, forumId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    Forum fr = new Forum();

                    fr.Id        = (Guid)dt.Rows[0]["Id"];
                    fr.Name      = dt.Rows[0]["Name"] != DBNull.Value ? dt.Rows[0]["Name"].ToString() : string.Empty;
                    fr.CreatedOn = (DateTime)dt.Rows[0]["CreatedOn"];

                    if (dt.Rows[0]["ParentForumId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference();
                        er.Id          = (Guid)dt.Rows[0]["ParentForumId"];
                        er.Name        = dt.Rows[0]["ParentForumIdName"] != DBNull.Value ? dt.Rows[0]["ParentForumIdName"].ToString() : string.Empty;
                        er.LogicalName = "new_forum";

                        fr.ParentForum = er;
                    }

                    MsCrmResultObject subjectRes = ForumHelper.GetForumSubjects(fr.Id, sda);
                    if (subjectRes.Success)
                    {
                        fr.ForumSubjects = (List <ForumSubject>)subjectRes.ReturnObject;
                    }

                    MsCrmResultObject subForumRes = ForumHelper.GetSubForums(fr.Id, portalUserId, sda);
                    if (subForumRes.Success)
                    {
                        fr.SubForums = (List <Forum>)subForumRes.ReturnObject;
                    }

                    returnValue.Success      = true;
                    returnValue.ReturnObject = fr;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result  = "M047"; //"Foruma ait herhangi bir bilgi bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }