Esempio n. 1
0
        public string GetMax(int bookId)
        {
            if (!CheckSecurity())
            {
                return(AccessDenied());
            }
            var query = new Query.Chapters(S.Server.sqlConnectionString);

            return(query.GetMax(bookId).ToString());
        }
Esempio n. 2
0
        public string GetList(int bookId, int start = 1, int length = 50, SortType sort = 0, bool includeCount = false)
        {
            if (!CheckSecurity())
            {
                return(AccessDenied());
            }
            var html        = new StringBuilder();
            var entries     = new Scaffold("/Services/Entries/entries.html", S.Server.Scaffold);
            var item        = new Scaffold("/Services/Entries/list-item.html", S.Server.Scaffold);
            var chapter     = new Scaffold("/Services/Entries/chapter.html", S.Server.Scaffold);
            var books       = new Query.Books(S.Server.sqlConnectionString);
            var query       = new Query.Entries(S.Server.sqlConnectionString);
            var chapters    = new Query.Chapters(S.Server.sqlConnectionString);
            var chapterlist = chapters.GetList(bookId);
            var list        = query.GetList(S.User.userId, bookId, start, length, (int)sort);
            var chapterInc  = -1;
            var book        = books.GetDetails(S.User.userId, bookId);

            entries.Data["book-title"] = book.title;

            if (list.Count > 0)
            {
                list.ForEach((Query.Models.Entry entry) =>
                {
                    if (chapterInc != entry.chapter && sort == 0)
                    {
                        if (entry.chapter > 0)
                        {
                            //display chapter
                            chapter.Data["chapter"] = "Chapter " + entry.chapter.ToString() + ": " +
                                                      chapterlist.Find((Query.Models.Chapter c) => { return(c.chapter == entry.chapter); }).title;
                            html.Append(chapter.Render());
                        }
                        chapterInc = entry.chapter;
                    }
                    item.Data["id"]           = entry.entryId.ToString();
                    item.Data["title"]        = entry.title;
                    item.Data["summary"]      = entry.summary;
                    item.Data["date-created"] = entry.datecreated.ToString("d/MM/yyyy");
                    html.Append(item.Render());
                });
                entries.Data["entries"] = html.ToString();
            }
            else
            {
                html.Append(S.Server.LoadFileFromCache("/Services/Entries/no-entries.html"));
            }

            return((includeCount == true ? list.Count + "|" : "") + entries.Render());
        }
Esempio n. 3
0
        public string CreateChapter(int bookId, int chapter, string title, string summary)
        {
            if (!CheckSecurity())
            {
                return(AccessDenied());
            }
            var query = new Query.Chapters(S.Server.sqlConnectionString);

            try
            {
                query.CreateChapter(bookId, chapter, title, summary);
            }
            catch (Exception)
            {
                return(Error());
            }
            return(Success());
        }
Esempio n. 4
0
        public string GetList(int bookId)
        {
            if (!CheckSecurity())
            {
                return(AccessDenied());
            }
            var list  = new List <chapter>();
            var query = new Query.Chapters(S.Server.sqlConnectionString);

            query.GetList(bookId).ForEach((Query.Models.Chapter chap) =>
            {
                list.Add(new chapter()
                {
                    num   = chap.chapter,
                    title = chap.title
                });
            });
            return(S.Util.Serializer.WriteObjectToString(list));
        }