Ejemplo n.º 1
0
        public List<WikiSpace> Get()
        {
            List<WikiSpace> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.WikiSpaces_SelectAll"
                , inputParamMapper: null, map: delegate(IDataReader reader, short set)
                {
                    WikiSpace ws = new WikiSpace();
                    int startingIndex = 0;

                    ws.Id = reader.GetSafeInt32(startingIndex++);
                    ws.Title = reader.GetSafeString(startingIndex++);
                    ws.ParentId = reader.GetSafeInt32(startingIndex++);

                    if (list == null)
                    {
                        list = new List<WikiSpace>();
                    }

                    list.Add(ws);
                }
            );
            return list;
        }
Ejemplo n.º 2
0
        private static WikiSpace MapWikiSpace(IDataReader reader)
        {
            WikiSpace ws = new WikiSpace();
            int startingIndex = 0;

            ws.Id = reader.GetSafeInt32(startingIndex++);
            ws.Title = reader.GetSafeString(startingIndex++);
            ws.ParentId = reader.GetSafeInt32(startingIndex++);
            return ws;
        }
Ejemplo n.º 3
0
        // Wiki by ID
        public static WikiPage GetWiki(int id)
        {
            WikiPage item = null;
            List<WikiPageSpace> wikiPageSpaces = null;

            WikiSpace ws;

            DataProvider.ExecuteCmd(GetConnection, "dbo.WikiPages_SelectByIdv2"
                , inputParamMapper: delegate (SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@Id", id);
                    //model binding

                }, map: delegate (IDataReader reader, short set)
                {
                    if (set == 0)
                    {
                        item = new WikiPage();
                        int startingIndex = 0; // startingOrdinal

                        item.Id = reader.GetSafeInt32(startingIndex++);
                        item.Title = reader.GetSafeString(startingIndex++);
                        item.URL = reader.GetSafeString(startingIndex++);
                        item.PublishDate = reader.GetSafeDateTime(startingIndex++);
                        item.Language = reader.GetSafeInt32(startingIndex++);
                        item.LastModifiedByUserId = reader.GetSafeString(startingIndex++);
                        item.ParentId = reader.GetSafeInt32(startingIndex++);

                    }
                    else if (set == 1)
                    {
                        WikiPageSpace wps = new WikiPageSpace();
                        int startingIndex = 0;

                        wps.WikiPageId = reader.GetSafeInt32(startingIndex++);
                        wps.WikiSpaceId = reader.GetSafeInt32(startingIndex++);

                        if (wikiPageSpaces == null)
                        {
                            wikiPageSpaces = new List<WikiPageSpace>();
                        }
                        wikiPageSpaces.Add(wps);
                    }
                    else if (set == 2)
                    {
                        ws = new WikiSpace();
                        int startingIndex = 0;

                        ws.Id = reader.GetSafeInt32(startingIndex++);
                        ws.Title = reader.GetSafeString(startingIndex++);
                        ws.ParentId = reader.GetSafeInt32(startingIndex++);

                        if (item != null)
                        {
                            if (wikiPageSpaces != null)
                                foreach (WikiPageSpace wikiPageSpace in wikiPageSpaces)
                                {
                                    if (item.Id == wikiPageSpace.WikiPageId && ws.Id == wikiPageSpace.WikiSpaceId)
                                    {
                                        if (item.WikiSpaces == null)
                                        {
                                            item.WikiSpaces = new List<WikiSpace>();
                                        }
                                        item.WikiSpaces.Add(ws);
                                    }

                                }
                        }

                    }
                    else if (set == 3)
                    {
                        WikiTags wt = new WikiTags();
                        int startingIndex = 0;

                        wt.WikiId = reader.GetSafeInt32(startingIndex++);
                        wt.TagId = reader.GetSafeInt32(startingIndex++);
                        wt.TagName = reader.GetSafeString(startingIndex++);

                        if (item.WikiTags == null)
                        {
                            item.WikiTags = new List<WikiTags>();
                        }
                        item.WikiTags.Add(wt);

                    }
                }

                );

            return item;
        }