Beispiel #1
0
        public WikiPage GetPageBySlug(string wikiSlug)
        {
            int wikiPageId = 0;

            DataProvider.ExecuteCmd(GetConnection, "dbo.WikiPages_SelectIdBySlug",
                                    inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Slug", wikiSlug);
            }, map : delegate(IDataReader reader, short set)
            {
                wikiPageId = reader.GetSafeInt32(0);
            }
                                    );

            if (wikiPageId > 0)
            {
                WikiPage page = _wikiService.GetWiki(wikiPageId);

                page.Contents = GetContentByPageId(page.Id);

                return(page);
            }

            return(null);
        }
Beispiel #2
0
        public HttpResponseMessage getWiki(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <WikiPage> response = new ItemResponse <WikiPage>();

            response.Item = _wikiService.GetWiki(id);
            return(Request.CreateResponse(response));
        }
        public int CreateSectionModule(SectionModule model)
        {
            int Id       = 0;
            int moduleId = model.ModuleId;

            //Module oldModule = new Module();
            if (model.ModuleId > 0)
            {
                Module oldModule = _moduleService.GetClassModules(moduleId);


                string name      = oldModule.ModuleName;
                int    sectionId = model.SectionId;

                ModuleAddRequest module = new ModuleAddRequest();
                module.ModuleName = name;
                module.SectionId  = sectionId;

                int newId = _moduleService.InsertModule(module);
                List <ModuleWikiPages> oldWikiPages = _moduleService.GetModuleWikis(moduleId);

                Id = newId;
                if (oldWikiPages != null)
                {
                    foreach (ModuleWikiPages wikiPage in oldWikiPages)
                    {
                        int    wikiPageId = wikiPage.WikiPageId;
                        string userId     = UserService.GetCurrentUserId();

                        WikiPage       copyWikiPage = _wikiService.GetWiki(wikiPageId);
                        WikiAddRequest newWikiPage  = new WikiAddRequest();
                        newWikiPage.Title = copyWikiPage.Title;
                        newWikiPage.URL   = copyWikiPage.URL;
                        //newWikiPage.Language = copyWikiPage.Language;
                        //newWikiPage.PublishDate = copyWikiPage.PublishDate;



                        int newPageId = _wikiService.Add(newWikiPage, userId);

                        _moduleService.AddWikiPage(Id, newPageId);
                    }
                }
            }
            return(Id);
        }