public static IEnumerable<string> UpdateReplicationDocuments(this RavenHelper raven, Store store) { var results = new Collection<string>(); foreach (var instance in store.Instances) { if (!raven.TryUpdateReplicationDocument(store, instance)) { results.Add( string.Format( "Failed to update replication destinations for {0}", instance.Url)); } } return results; }
public ActionResult Update(TempInput sendInfo) { //var post = RavenSession.Load<Post>(input.Id) ?? new Post { CreatedAt = DateTimeOffset.Now };//Post is an empty tool here //////////////// sendInfo.Id = "0"; var post = RavenSession.Load<Post>(sendInfo.Id) ?? new Post { CreatedAt = DateTimeOffset.Now };//Post is an empty tool here //input.MapPropertiesToInstance(post);//Entering data /////////////////////// post.Title = sendInfo.Title; if (sendInfo.AllowComments == "on") post.AllowComments = true; else post.AllowComments = false; post.Body = sendInfo.Body; post.CreatedAt = DateTimeOffset.Now; //Convert PublishAt (string) into dateTime string mm = sendInfo.PublishAt.Substring(0, 2); int mmInt = int.Parse(mm); string dd = sendInfo.PublishAt.Substring(3,2); int ddInt = int.Parse(dd); string yy = sendInfo.PublishAt.Substring(6, 4); int yyInt = int.Parse(yy); // Convert into date DateTime TempDate=new DateTime(yyInt,mmInt,ddInt); // Convert into DateTimeOffset DateTimeOffset TempDateOffSet=new DateTimeOffset(TempDate); // Entering the date into post post.PublishAt = TempDateOffSet; // Entering the tag string tempTag = sendInfo.Tags; ICollection<string> t=new Collection<string>(); t.Add(tempTag); post.Tags.Add(tempTag); //if (!ModelState.IsValid) //////////////////// // return View("Edit", input); ////////////////// // Be able to record the user making the actual post var user = RavenSession.GetCurrentUser(); if (string.IsNullOrEmpty(post.AuthorId)) { post.AuthorId = user.Id; } else { post.LastEditedByUserId = user.Id; post.LastEditedAt = DateTimeOffset.Now; } if (post.PublishAt <= DateTimeOffset.Now) { var postScheduleringStrategy = new PostSchedulingStrategy(RavenSession, DateTimeOffset.Now); post.PublishAt = postScheduleringStrategy.Schedule(); post.PublishAt = DateTimeOffset.Now; post.CreatedAt = DateTimeOffset.Now; } // Actually save the post now RavenSession.Store(post); //if (input.IsNewPost()) ////////////////////// //{ // Create the post comments object and link between it and the post var comments = new PostComments { Comments = new List<PostComments.Comment>(), Spam = new List<PostComments.Comment>(), Post = new PostComments.PostReference { Id = post.Id, PublishAt = post.PublishAt, } }; RavenSession.Store(comments); post.CommentsId = comments.Id; //} //////////////// return RedirectToAction("Details", new { Id = post.MapTo<PostReference>().DomainId }); }