示例#1
0
        public ActionResult Create(BasicBlogViewModel vm)
        {
            //this is for basic validation
            if (!ModelState.IsValid)
                return View(vm);

            var existingBlog = RavenSession.Query<Blog>().Where(x => x.Name == vm.Name).FirstOrDefault();

            if (existingBlog != null)
                this.PropertyValidationMessage("Name", string.Format("Please pick another name. {0} has already been taken.", vm.Name));

            //do another check after this 'advanced' validation
            if (!ModelState.IsValid)
                return View(vm);

            var blog = new Blog();
            blog.Id = Blog.NewId(vm.Name).Full();
            blog.Guid = Stamp.GUID().ToString();
            blog.Name = vm.Name;
            blog.Title = vm.Title;
            blog.Description = vm.Description;
            blog.Keywords = vm.Keywords;

            RavenSession.Store(blog);

            //take care of the temporary account

            var transient = CookieMonster.GetFromCookie<TransientAccount>(Request.Cookies[TransientAccount.COOKIE_NAME]);
            if (!transient.IsFound)
            {
                var init = new TransientAccount();
                init.BlogGuids.Add(blog.Guid);
                init.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(init, TransientAccount.COOKIE_NAME));
            }
            else
            {
                transient.Item.BlogGuids.Add(blog.Guid);
                transient.Item.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(transient.Item, TransientAccount.COOKIE_NAME));
            }

            this.RavenSession.SaveChanges();

            return Redirect("/b/" + blog.Name);
        }
示例#2
0
        public ActionResult FixTemporaryLogin(string name)
        {
            var blog = RavenSession.Query<Blog>().Where(x => x.Name == name).FirstOrDefault();

            if (blog == null)
                return HttpNotFound();

            var transient = CookieMonster.GetFromCookie<TransientAccount>(Request.Cookies[TransientAccount.COOKIE_NAME]);
            if (!transient.IsFound)
            {
                var init = new TransientAccount();
                init.BlogGuids.Add(blog.Guid);
                init.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(init, TransientAccount.COOKIE_NAME));
            }
            else
            {
                transient.Item.BlogGuids.Add(blog.Guid);
                transient.Item.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(transient.Item, TransientAccount.COOKIE_NAME));
            }

            return Content("The temporary login has been issued");
        }
示例#3
0
 public ActionResult RinseAccount()
 {
     var transient = CookieMonster.GetFromCookie<TransientAccount>(Request.Cookies[TransientAccount.COOKIE_NAME]);
     if (transient.IsFound)
     {
         var account = new TransientAccount();
         account.RiverGuids.AddRange(transient.Item.RiverGuids.Distinct());
         account.SyndicationGuids.AddRange(transient.Item.SyndicationGuids.Distinct());
         account.BlogGuids.AddRange(transient.Item.BlogGuids.Distinct());
         account.OpmlGuids.AddRange(transient.Item.OpmlGuids.Distinct());
         account.DateCreated = transient.Item.DateCreated;
         account.LastModified = DateTime.UtcNow;
         Response.Cookies.Add(CookieMonster.SetCookie(account, TransientAccount.COOKIE_NAME));
         return Content("Account has been rinsed");
     }
     else
     {
         return Content("There is no transient account to rinse");
     }
 }
示例#4
0
        public ActionResult Index(string name)
        {
            var id = SyndicationList.NewId(name);

            var list = RavenSession.Load<SyndicationList>(id.Full());

            if (list != null)
            {
                ViewBag.Title = list.Title;
                ViewBag.Description = Server.HtmlEncode(list.Description);
                ViewBag.Keywords = Server.HtmlEncode(list.Keywords);
                ViewBag.Name = list.Name;

                var edit = CookieMonster.GetFromCookie<TransientAccount>(Request.Cookies[TransientAccount.COOKIE_NAME]);

                if (edit.IsFound && edit.Item.IsSyndicationListFound(list.Guid))
                {
                    ViewBag.EditLink = "/manage/syndication/sources/?guid=" + list.Guid;
                }
                else
                {
                    if (!edit.IsFound)
                    {
                        var init = new TransientAccount();
                        init.SyndicationGuids.Add(list.Guid);
                        init.MarkUpdated();
                        Response.Cookies.Add(CookieMonster.SetCookie(init, TransientAccount.COOKIE_NAME));
                    }
                    else //
                    {
                        edit.Item.SyndicationGuids.Add(list.Guid);
                        edit.Item.MarkUpdated();
                        Response.Cookies.Add(CookieMonster.SetCookie(edit.Item, TransientAccount.COOKIE_NAME));
                    }
                }

                return View();
            }
            else
                return HttpNotFound();
        }
示例#5
0
        public ActionResult Create(BasicRiverWallViewModel vm)
        {
            //this is for basic validation
            if (!ModelState.IsValid)
                return View(vm);

            var river = RavenSession.Query<RiverWall>().Where(x => x.Name == vm.Name).FirstOrDefault();

            if (river != null)
                this.PropertyValidationMessage("Name", string.Format("Please pick another name. {0} has already been taken.", vm.Name));

            //do another check after this 'advanced' validation
            if (!ModelState.IsValid)
                return View(vm);

            var wall = new RiverWall();
            wall.Id = RiverWall.NewId(vm.Name).Full();
            wall.Guid = Stamp.GUID().ToString();
            wall.Name = vm.Name;
            wall.Title = vm.Title;
            wall.Description = vm.Description;
            wall.Keywords = vm.Keywords;
            wall.Template = DefaultRiverTemplate.Get();
            wall.Sources = DefaultRiverSubscription.Get();

            RavenSession.Store(wall);

            //take care of the temporary account

            var transient = CookieMonster.GetFromCookie<TransientAccount>(Request.Cookies[TransientAccount.COOKIE_NAME]);
            if (!transient.IsFound)
            {
                var init = new TransientAccount();
                init.RiverGuids.Add(wall.Guid);
                init.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(init, TransientAccount.COOKIE_NAME));
            }
            else
            {
                transient.Item.RiverGuids.Add(wall.Guid);
                transient.Item.MarkUpdated();
                Response.Cookies.Add(CookieMonster.SetCookie(transient.Item, TransientAccount.COOKIE_NAME));
            }

            this.RavenSession.SaveChanges();

            return RedirectToAction("Sources", new { guid = wall.Guid });
        }