Пример #1
0
        public ActionResult Edit(Edit model)
        {
            var settings = new Settings
                               {
                                   KeepUsersOnlineFor = model.KeepUsersOnlineFor,
                                   EnableComments =  model.EnableComments == Status.Enabled,
                                   CommentsRequireApproval = model.CommentsRequireApproval == Status.Enabled
                               };

            Settings.Save(settings);
            ViewBag.Success = true;

            return View(Mapper.Map<Settings, Edit>(settings));
        }
Пример #2
0
        private void BuildSampleData(IDocumentStore store)
        {
            using (var session = store.OpenSession())
            {
                var settings = new Settings();
                if (session.Load<Settings>(settings.Id) == null)
                {
                    session.Store(settings);
                }

                if (session.Load<User>("admin") == null)
                {
                    session.Store(new User("admin", "password"));
                }

                if (session.Query<Post>().Count() == 0)
                {
                    var post1 = new Post("Sample Blog Post", "sample-blog-post", "admin",
                        "<p>Welcome to the Sura Blog system</p><p>This is an automatically generated sample post</p>");
                    post1.Publish();
                    post1.Tags.Add("sample");
                    session.Store(post1);

                    var post2 = new Post("Another sample post", "another-sample-post", "admin",
                        "<p>This is another sample blog post</p>");
                    post2.Publish();
                    post2.Tags.Add("sample");
                    post2.Tags.Add("amazing");
                    session.Store(post2);

                    var post3 = new Post("A scheduled sample post", "scheduled-sample-post", "admin",
                        "<p>This is a sample blog post scheduled to post on 1st January 2013.</p>");
                    post3.ScheduleFor(new DateTimeOffset(new DateTime(2013, 1, 1)));
                    post3.Tags.Add("scheduled");
                    session.Store(post3);

                    var post4 = new Post("A draft sample post", "draft-sample-post", "admin",
                        "<p>This sample post is marked as a draft copy.</p>");
                    post4.MarkAsDraft();
                    post4.Tags.Add("sample");
                    post4.Tags.Add("draft");
                    session.Store(post4);
                }

                session.SaveChanges();
            }
        }
Пример #3
0
 public CommentsController(IDocumentSession session, ISettingsService settings)
     : base(session, settings)
 {
     _settings = settings.Load();
 }