Beispiel #1
0
        public ActionResult CreatePage(WikiPage page)
        {
            MongoCollection<WikiPage> pages = new MongoServer().GetDatabase("MongoWiki").GetCollection<WikiPage>("WikiPage");

            pages.Insert(page);

            return this.RedirectToAction("ViewPage", new { page = page.URL });
        }
Beispiel #2
0
        public ActionResult EditPage(WikiPage page)
        {
            MongoCollection<WikiPage> pages = new MongoServer().GetDatabase("MongoWiki").GetCollection<WikiPage>("WikiPage");

            // Get the previous version
            WikiPage prevPage = pages.FindOne(new { URL = page.URL });

            // Save the updateone
            pages.UpdateOne(new { URL = page.URL }, page);

            // Save the previous revision
            MongoCollection<WikiPageRevision> revs = new MongoServer().GetDatabase("MongoWiki").GetCollection<WikiPageRevision>("WikiPageRevision");
            WikiPageRevision rev = new WikiPageRevision(prevPage);
            rev.RevisionDate = DateTime.Now;
            revs.Insert(rev);

            return this.RedirectToAction("ViewPage", new { page = page.URL });
        }
Beispiel #3
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            DateTime createDate;
            WikiPage page = new WikiPage();

            page.ID = controllerContext.HttpContext.Request.Form["ID"];
            page.Title = controllerContext.HttpContext.Request.Form["Title"];
            page.URL = Utility.FormatForUrl(page.Title);
            page.Body = controllerContext.HttpContext.Request.Form["Body"];
            page.LastUpdateDate = DateTime.Now;

            if (DateTime.TryParse(controllerContext.HttpContext.Request.Form["CreateDate"], out createDate))
                page.CreateDate = createDate;
            else
                page.CreateDate = DateTime.Now;

            return page;
        }
Beispiel #4
0
 public WikiPageRevision(WikiPage page)
     : base(page.ID, page.Title, page.URL, page.Body, page.CreateDate)
 {
 }