public RiverTemplateViewModel(RiverWall wall) { RiverGuid = wall.Guid; RiverName = wall.Name; RiverTitle = wall.Title; LessCss = wall.Template.LessCss.Text; JavaScript = wall.Template.JavaScript.Text; CoffeeScript = wall.Template.CoffeeScript.Text; FeedTemplate = wall.Template.FeedTemplate; WallTemplate = wall.Template.WallTemplate; HtmlHeadInline = wall.Template.HtmlHeadInline; HtmlBodyInline = wall.Template.HtmlBodyInline; }
public void SaveRiverWall() { var wall = new RiverWall(); wall.Id = RiverWall.NewId("dodyg").Full(); wall.Guid = Stamp.GUID().ToString(); wall.Name = "dodyg"; wall.Template = DefaultRiverTemplate.Get(); wall.Sources = DefaultRiverSubscription.Get(); wall.Title = "Dody's Wall"; wall.Description = "This is Dody Gunawinata's Wall"; wall.Keywords = "dody, gunawinata, awesome"; using (var store = Raven.GetStoreFromServer()) { using (var session = store.OpenSession(Raven.DATABASE_NAME)) { session.Store(wall); session.SaveChanges(); } } }
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 }); }
IQuerySetOne<HostAndPath> GetFeed(RiverWall wall, string feedName) { if (wall != null) { var rivers = wall.Sources.Items; var feed = rivers.Where(x => x.Name == feedName).FirstOrDefault(); if (feed != null) { var uri = feed.JSONPUri; return new QuerySetOne<HostAndPath>(new HostAndPath ( host: Texts.FromUriHost(uri), path: uri.PathAndQuery )); } else return new QuerySetOne<HostAndPath>(null); } else { return new QuerySetOne<HostAndPath>(null); } }