Exemple #1
0
        public static MsCrmResultObject GetSubForums(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)
		                                    JOIN
			                                    new_new_forum_new_role AS fr (NOLOCK)
				                                    ON
				                                    fr.new_forumid=f.new_forumId
		                                    JOIN
			                                    new_role AS r (NOLOCK)
				                                    ON
				                                    r.new_roleId=fr.new_roleid
				                                    AND
				                                    r.statecode=0
				                                    AND
				                                    r.statuscode=1 --Active
		                                    JOIN
			                                    new_new_user_new_role AS ur (NOLOCK)
				                                    ON
				                                    ur.new_userid='{1}'
                                    WHERE
	                                    f.new_parentforumId='{0}'
                                    AND
	                                    f.statecode=0
                                    AND
	                                    f.statuscode=1 --Active
                                    ORDER BY
                                        f.CreatedOn";
                #endregion

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

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

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Forum fr = new Forum();

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

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

                            fr.ParentForum = er;
                        }

                        MsCrmResultObject subFrRes = ForumHelper.GetSubForums(fr.Id, portalUserId, sda);

                        if (subFrRes.Success)
                        {
                            fr.SubForums = (List <Forum>)subFrRes.ReturnObject;
                        }

                        lstSubFr.Add(fr);
                    }

                    returnValue.Success      = true;
                    returnValue.ReturnObject = lstSubFr;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result  = "Alt forum kaydı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }
Exemple #2
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);
        }
Exemple #3
0
        public static MsCrmResultObject GetUserForums(Guid portalId, 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)
		                                JOIN
			                                new_new_forum_new_role AS fr (NOLOCK)
				                                ON
				                                fr.new_forumid=f.new_forumId
		                                JOIN
			                                new_role AS r (NOLOCK)
				                                ON
				                                r.new_roleId=fr.new_roleid
				                                AND
				                                r.statecode=0
				                                AND
				                                r.statuscode=1 --Active
		                                JOIN
			                                new_new_user_new_role AS ur (NOLOCK)
				                                ON
				                                ur.new_userid='{1}'
                                WHERE
	                                f.new_parentforumId IS NULL
                                AND
	                                f.new_portalId='{0}'
                                AND
	                                f.statecode=0
                                AND
	                                f.statuscode=1 --Active
                                ORDER BY
                                    f.CreatedOn DESC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, portalUserId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <Forum> lstForum = new List <Forum>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        MsCrmResultObject frRes = ForumHelper.GetForumInfo((Guid)dt.Rows[i]["Id"], portalUserId, sda);

                        if (frRes.Success)
                        {
                            lstForum.Add((Forum)frRes.ReturnObject);
                        }
                    }

                    returnValue.Success      = true;
                    returnValue.ReturnObject = lstForum;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result  = "M046"; //"Forum kaydı bulunamadı!!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }