public BlogForm(Blog blog) : this() { currentBlog = blog; nameText.Text = currentBlog.Name; authorText.Text = currentBlog.Author; }
public void TestMethod1() { BlogMapper m = new BlogMapper(); Blog b = new Blog(); m.Insert(b); b = m.Get(1); }
public void SimpleOperations() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog)); Recreate(); Post.DeleteAll(); Blog.DeleteAll(); var blogs = from b in Blog.Queryable select b; Assert.IsNotNull(blogs); Assert.AreEqual(0, blogs.Count()); var blog = new Blog { Name = "hammett's blog", Author = "hamilton verissimo" }; blog.Save(); blogs = from b in Blog.Queryable select b; Assert.IsNotNull(blogs); Assert.AreEqual(1, blogs.Count()); var retrieved = Blog.Queryable.First(); Assert.IsNotNull(retrieved); Assert.AreEqual(blog.Name, retrieved.Name); Assert.AreEqual(blog.Author, retrieved.Author); }
public BlogRelatedViewModel(string title) { using (var context = new DataContext()) { // Try permalink first TheBlog = context.Blogs.FirstOrDefault(x => x.PermaLink == title); MaxBlogCount = BlogListModel.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad; // If no go then try title as a final back up if (TheBlog == null) { title = title.Replace(Utils.ContentGlobals.BLOGDELIMMETER, " "); TheBlog = context.Blogs.FirstOrDefault(x => x.Title == title); } if (TheBlog != null && TheBlog.Tags != null) { List<string> tags = TheBlog.Tags.Split(',').ToList(); RelatedPosts = context.Blogs.Where(x => x.BlogId != TheBlog.BlogId && tags.Contains(x.Tags) && x.MainCategory == TheBlog.MainCategory) .OrderByDescending(blog => blog.Date) .Take(MaxBlogCount) .ToList(); if (RelatedPosts.Count > 0) { LastBlogId = RelatedPosts.LastOrDefault().BlogId; } } } }
public void BlogEntry_is_Added_to_Blog() { var blogEntry = new BlogEntry(string.Empty); var blog = new Blog(); blog.Add(blogEntry); Assert.AreEqual(1, blog.Entries.Count()); }
void dummy() { BlogMapper m = new BlogMapper(); Blog b = new Blog(); m.Insert(b); b = m.Get(1); }
public void GivenANewBlog_ThenItsLastUpdatedDateIsNow() { var blog = new Blog(); Assert.That(blog.LastUpdated, Is.LessThanOrEqualTo(DateTime.Now)); }
public void CanPerformDynamicQueryAndGetValidResults() { var blogOne = new Blog { Title = "one", Category = "Ravens" }; var blogTwo = new Blog { Title = "two", Category = "Rhinos" }; var blogThree = new Blog { Title = "three", Category = "Rhinos" }; db.Documents.Put("blogOne", null, RavenJObject.FromObject(blogOne), new RavenJObject(), null); db.Documents.Put("blogTwo", null, RavenJObject.FromObject(blogTwo), new RavenJObject(), null); db.Documents.Put("blogThree", null, RavenJObject.FromObject(blogThree), new RavenJObject(), null); var results = db.ExecuteDynamicQuery(null,new IndexQuery() { PageSize = 128, Start = 0, Cutoff = SystemTime.UtcNow, Query = "Title.Length:3 AND Category:Rhinos" }, CancellationToken.None); Assert.Equal(1, results.Results.Count); Assert.Equal("two", results.Results[0].Value<string>("Title")); Assert.Equal("Rhinos", results.Results[0].Value<string>("Category")); }
public BlogRelatedViewModel(string title) { // Try permalink first TheBlog = Context.Blogs.FirstOrDefault(x => x.PermaLink == title); var model = new BlogListModel(Context); MaxBlogCount = model.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad; SkipBlogs = MaxBlogCount; // If no go then try title as a final back up if (TheBlog == null) { title = title.Replace(ContentGlobals.BLOGDELIMMETER, " "); TheBlog = Context.Blogs.FirstOrDefault(x => x.Title == title); } if (TheBlog == null || TheBlog.Tags == null) { return; } var relPosts = Context.Blogs.Where(x => x.BlogId != TheBlog.BlogId && x.IsActive) .OrderByDescending(blog => blog.Date).ToList(); relPosts.RemoveAll(posts => !posts.Tags.Intersect(TheBlog.Tags).Any() && posts.Category.CategoryId != TheBlog.Category.CategoryId); RelatedPosts = relPosts.Take(5).ToList(); }
static void Main(string[] args) { Author author = new Author(); author.FullName = "Gang of Four"; author.Age = 22; Blog blog = new Blog(); blog.Id = 1; blog.Name = "Design Patterns"; blog.Comments.Add("Visitor pattern"); blog.Comments.Add("Abstract factory pattern"); blog.Comments.Add("Composite pattern"); blog.Author = author; ISerializerFactory serializerFactory = new UnicodeXmlSerializerFactory(); var service = new BlogDataExchangeService(); service.SerializerFactory = serializerFactory; System.Console.WriteLine("{0}:\n{1}\n", "Full as Unicode XML Document", service.GetFull(blog)); System.Console.WriteLine("{0}:\n{1}\n", "Header as Unicode XML Document", service.GetHeader(blog)); System.Console.WriteLine("{0}:\n{1}\n", "Exchange as Unicode XML Document", service.GetFullForExchange(blog)); System.Console.WriteLine(); serializerFactory = new JsonSerializerFactory(); service.SerializerFactory = serializerFactory; System.Console.WriteLine("{0}:\n{1}\n", "Full as JSON Document", service.GetFull(blog)); System.Console.WriteLine("{0}:\n{1}\n", "Header as JSON Document", service.GetHeader(blog)); System.Console.WriteLine("{0}:\n{1}\n", "Exchange as JSON Document", service.GetFullForExchange(blog)); System.Console.WriteLine("Execution finished. Press a key to exit."); System.Console.ReadLine(); }
public void FetchEnum_Join_on_a_HasMany_property_should_not_return_duplicate_records() { Blog[] blogs = Blog.FindAll(); Assert.IsNotNull(blogs); Assert.AreEqual(0, blogs.Length); var blog = new Blog() { Name = "Test blog", Author = "Eric Bowen" }; blog.Save(); var post = new Post(blog, "Post1", "Content1", "Category1"); post.Save(); blog.Posts.Add(post); var post2 = new Post(blog, "Post2", "Content2", "Category2"); post2.Save(); blog.Posts.Add(post2); blog.Save(); blogs = Blog.FindAll(); Assert.IsNotNull(blogs); Assert.AreEqual(1, blogs.Length); }
public static void BelongTo(this IList<Post> posts, Blog blog) { foreach (Post postItem in posts) { postItem.Blog = blog; } }
public ActionResult AddBlog() { // Create a new blog to be passed to the edit blog action Blog blog = new Blog { IsActive = false, Title = "New Blog", Date = DateTime.UtcNow, Tags = new List<BlogTag> { Utils.GetNewBlogTag() }, BlogAuthor = Context.BlogUsers.First(usr => usr.UserId == 1) // This is anonymous and can't be deleted }; var cat = Utils.GetUncategorizedCategory(); blog.Category = cat; Context.Blogs.Add(blog); Context.SaveChanges(); // Update the blog title / permalink with the new id we now have var blogId = blog.BlogId.ToString(); blog.Title = blog.Title + " " + blogId; Context.SaveChanges(); return RedirectToAction("EditBlog", "Blog", new { id = blogId }); }
private static void CreateBlog() { var blog = new Blog {BloggerName = "Julie", Title = "EF41 Blog", DateCreated=DateTime.Now}; //var blog = new Blog() { Title = "This is a blog with a really long blog title" }; var db = new Context(); db.Blogs.Add(blog); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var entityError in ex.EntityValidationErrors) { Console.WriteLine(entityError.Entry.Entity.GetType().Name); foreach (var error in entityError.ValidationErrors) { Console.WriteLine("{0}: {1}", error.PropertyName, error.ErrorMessage); } } Console.ReadKey(); } }
public PostViewModel(Blog blog, Blogger blogger, Post post, List<Post> posts) { Post = post; Blogger = blogger; Blog = blog; Posts = posts; }
public void SimpleOperations() { Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer); Blog[] blogs = Blog.FindAll(); Assert.IsNotNull(blogs); Assert.AreEqual(0, blogs.Length); Blog blog = new Blog(); blog.Name = "hammett's blog"; blog.Author = "hamilton verissimo"; blog.Save(); blogs = Blog.FindAll(); Assert.IsNotNull(blogs); Assert.AreEqual(1, blogs.Length); Blog retrieved = blogs[0]; Assert.IsNotNull(retrieved); Assert.AreEqual(blog.Name, retrieved.Name); Assert.AreEqual(blog.Author, retrieved.Author); }
public void AnExceptionInvalidatesTheScopeAndPreventItsFlushing() { using (new SessionScope()) { Post.DeleteAll(); Blog.DeleteAll(); } Post post; // Prepare using(new SessionScope()) { var blog = new Blog {Author = "hammett", Name = "some name"}; blog.Save(); post = new Post(blog, "title", "contents", "castle"); post.Save(); } using(var session = new SessionScope()) { Assert.IsFalse(session.HasSessionError); Assert.Throws<ActiveRecordException>(() => { post = new Post(new Blog(100), "title", "contents", "castle"); post.Save(); session.Flush(); }); Assert.IsTrue(session.HasSessionError); } }
internal Article(Blog blog, string uri, DateTime date, string title) { this.blog = blog; this.uri = uri; this.date = date; this.title = title; }
public void AuthenticateRequest(Blog blog, HttpContextBase context) { string authHeader = context.Request.Headers["Authorization"]; if(String.IsNullOrEmpty(authHeader)) { return; } if(authHeader.IndexOf("Basic ") == 0) { byte[] bytes = Convert.FromBase64String(authHeader.Remove(0, 6)); string authString = Encoding.Default.GetString(bytes); string[] usernamepassword = authString.Split(':'); if(context.Authenticate(blog, usernamepassword[0], usernamepassword[1], false)) { context.User = new GenericPrincipal(new GenericIdentity(usernamepassword[0]), null); } else { SendAuthRequest(context); } } }
/// <summary> /// Posts trackbacks and pingbacks for the specified entry. /// </summary> public static void Run(Entry entry, Blog blog, BlogUrlHelper urlHelper) { if (!blog.TrackbacksEnabled) { return; } if (!Config.Settings.Tracking.EnablePingBacks && !Config.Settings.Tracking.EnableTrackBacks) { return; } if (entry != null) { VirtualPath blogUrl = urlHelper.BlogUrl(); Uri fullyQualifiedUrl = blogUrl.ToFullyQualifiedUrl(blog); var notify = new Notifier { FullyQualifiedUrl = fullyQualifiedUrl.AbsoluteUri, BlogName = blog.Title, Title = entry.Title, PostUrl = urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(blog), Description = entry.HasDescription ? entry.Description : entry.Title, Text = entry.Body }; //This could take a while, do it on another thread ThreadHelper.FireAndForget(notify.Notify, "Exception occured while attempting trackback notification"); } }
public EditBlogViewModel(string blogId) { BlogId = Int32.Parse(blogId); _memUser = Membership.GetUser(HttpContext.Current.User.Identity.Name); SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath() + "blog/"; using (var context = new DataContext()) { ThisBlog = context.Blogs.FirstOrDefault(x => x.BlogId == BlogId); // Make sure we have a permalink set if (String.IsNullOrEmpty(ThisBlog.PermaLink)) { ThisBlog.PermaLink = ContentUtils.GetFormattedUrl(ThisBlog.Title); context.SaveChanges(); } // Get the list of Authors for the drop down select BlogUsers = context.BlogUsers.Where(x => x.IsActive == true).OrderBy(x => x.DisplayName).ToList(); Categories = context.BlogCategories.Where(x => x.IsActive == true).ToList(); UsersSelectedCategories = new List<string>(); _thisUser = context.Users.FirstOrDefault(x => x.Username == _memUser.UserName); } // Get the admin modules that will be displayed to the user in each column getAdminModules(); }
public void CanAddAndGetBlog() { Blog b1 = null; try { // Arrange b1 = new Blog("myblog", "My blog", "Blah ...", OwnerId1); // Act BlogRepository.Add(b1); Blog b2 = BlogRepository.Get(b1.Id); // Assert Assert.IsNotNull(b2); Assert.AreEqual(b1.Id, b2.Id); Assert.AreNotEqual(b1.Id, Guid.Empty, "Persistence layer must assign IDs"); Assert.AreEqual(b1.Key, b2.Key); Assert.AreEqual(b1.Title, b2.Title); Assert.AreEqual(b1.Description, b2.Description); Assert.AreEqual(b1.OwnerId, b2.OwnerId); } finally { BlogRepository.Remove(b1.Id); } }
public BlogsByUserViewModel(string username) { // Get back to the original name before url conversion BlogUsername = username.Replace(ContentGlobals.BLOGDELIMMETER, " "); using (var context = new DataContext()) { // Get User based on authorid TheBlogUser = context.BlogUsers.FirstOrDefault(x => x.Username == BlogUsername); MaxBlogCount = BlogListModel.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad; BlogTitle = BlogListModel.GetBlogSettings().BlogTitle; BlogsByUser = context.Blogs.Where(x => x.Author == BlogUsername && x.IsActive) .OrderByDescending(blog => blog.Date) .Take(MaxBlogCount) .ToList(); // Try permalink first TheBlog = BlogsByUser.FirstOrDefault(x => x.Author == BlogUsername); if (BlogsByUser.Count > 0) { LastBlogId = BlogsByUser.LastOrDefault().BlogId; } } }
public virtual Post CreateAndThrowException(Blog blog, String title, String contents, String category) { Post post = new Post(blog, title, contents, category); post.Save(); throw new Exception("Dohhh!"); }
public BlogViewModel(Blog blog, List<Post> posts, List<Blog> blogs, List<Blogger> bloggers, int totalPosts) { Blog = blog; Posts = posts; Blogs = blogs; Bloggers = bloggers; TotalPosts = totalPosts; }
public virtual void ModifyAndThrowException(Blog blog, String newName) { blog.Name = newName; blog.Save(); throw new Exception("Doh!"); }
public override void DeleteBlog(Blog blog) { var blogToDelete = (from b in db.Blogs where (b.UserName == blog.Author && b.Mood == blog.Mood && b.BlogText == blog.Text) select b).FirstOrDefault(); db.Blogs.DeleteOnSubmit(blogToDelete); db.SubmitChanges(); }
/// <summary> /// Gets the storage folder for the blog. /// </summary> internal string GetFolder(Blog blog) { // if "blog" == null, this means it's the primary instance being asked for -- which // is in the root of BlogConfig.StorageLocation. string location = blog == null ? BlogConfig.StorageLocation : blog.StorageLocation; var p = location.Replace("~/", string.Empty); return Path.Combine(HttpRuntime.AppDomainAppPath, p); }
public virtual Post Create(Blog blog, String title, String contents, String category) { Post post = new Post(blog, title, contents, category); post.Save(); return post; }
public virtual Blog Create(String name, String author) { Blog blog = new Blog(); blog.Name = name; blog.Author = author; blog.Save(); return blog; }
protected ICollection <LinkCategory> GetArchiveCategories(Blog blog) { return(new List <LinkCategory> { UIData.Links(CategoryType.StoryCollection, blog, Url) }); }
public async Task Edit(Blog blog) { await _unitOfWork.BlogRepository.Update(_mapper.Map <BlogEntity>(blog)); }
public void TestCachingPolicy() { var funcs = new List <string>(); var checkQry = (Action <DbQueryInfo>)(qry => { var set = qry.AffectedEntitySets.Single(); Assert.AreEqual("Post", set.Name); Assert.AreEqual(1, qry.Parameters.Count); Assert.AreEqual(-5, qry.Parameters[0].Value); Assert.AreEqual(DbType.Int32, qry.Parameters[0].DbType); Assert.IsTrue(qry.CommandText.EndsWith("WHERE [Extent1].[BlogId] > @p__linq__0")); } ); Policy.CanBeCachedFunc = qry => { funcs.Add("CanBeCached"); checkQry(qry); return(true); }; Policy.CanBeCachedRowsFunc = (qry, rows) => { funcs.Add("CanBeCachedRows"); Assert.AreEqual(3, rows); checkQry(qry); return(true); }; Policy.GetCachingStrategyFunc = qry => { funcs.Add("GetCachingStrategy"); checkQry(qry); return(DbCachingMode.ReadWrite); }; Policy.GetExpirationTimeoutFunc = qry => { funcs.Add("GetExpirationTimeout"); checkQry(qry); return(TimeSpan.MaxValue); }; using (var ctx = GetDbContext()) { var blog = new Blog(); ctx.Posts.Add(new Post { Title = "Foo", Blog = blog }); ctx.Posts.Add(new Post { Title = "Bar", Blog = blog }); ctx.Posts.Add(new Post { Title = "Baz", Blog = blog }); ctx.SaveChanges(); int minId = -5; Assert.AreEqual(3, ctx.Posts.Where(x => x.BlogId > minId).ToArray().Length); // Check that policy methods are called in correct order with correct params. Assert.AreEqual( new[] { "GetCachingStrategy", "CanBeCached", "CanBeCachedRows", "GetExpirationTimeout" }, funcs.ToArray()); } }
public void RssWriterSendsWholeFeedWhenRFC3229Disabled() { UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "", "Subtext.Web"); var blogInfo = new Blog(); BlogRequest.Current.Blog = blogInfo; blogInfo.Host = "localhost"; blogInfo.Subfolder = ""; blogInfo.Email = "*****@*****.**"; blogInfo.RFC3229DeltaEncodingEnabled = false; blogInfo.TimeZoneId = TimeZonesTest.PacificTimeZoneId; HttpContext.Current.Items.Add("BlogInfo-", blogInfo); var entries = new List <Entry>(CreateSomeEntriesDescending()); var subtextContext = new Mock <ISubtextContext>(); subtextContext.FakeSyndicationContext(blogInfo, "/Subtext.Web/", "Subtext.Web", null); Mock <BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper); urlHelper.Setup(u => u.BlogUrl()).Returns("/Subtext.Web/"); urlHelper.Setup(u => u.EntryUrl(It.IsAny <Entry>())).Returns <Entry>(e => "/Subtext.Web/whatever/" + e.Id); var writer = new RssWriter(new StringWriter(), entries, DateTime.ParseExact("07/14/2003", "MM/dd/yyyy", CultureInfo.InvariantCulture), false, subtextContext.Object); string expected = @"<rss version=""2.0"" xmlns:dc=""http://purl.org/dc/elements/1.1/"" xmlns:trackback=""http://madskills.com/public/xml/rss/module/trackback/"" xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" xmlns:slash=""http://purl.org/rss/1.0/modules/slash/"" xmlns:copyright=""http://blogs.law.harvard.edu/tech/rss"" xmlns:image=""http://purl.org/rss/1.0/modules/image/"">" + Environment.NewLine + indent() + "<channel>" + Environment.NewLine + indent(2) + "<title />" + Environment.NewLine + indent(2) + "<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(2) + "<description />" + Environment.NewLine + indent(2) + "<language>en-US</language>" + Environment.NewLine + indent(2) + "<copyright>Subtext Weblog</copyright>" + Environment.NewLine + indent(2) + "<generator>{0}</generator>" + Environment.NewLine + indent(2) + "<image>" + Environment.NewLine + indent(3) + "<title />" + Environment.NewLine + indent(3) + "<url>http://localhost/Subtext.Web/images/RSS2Image.gif</url>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(3) + "<width>77</width>" + Environment.NewLine + indent(3) + "<height>60</height>" + Environment.NewLine + indent(2) + "</image>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + "<title>Title of 1004.</title>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/whatever/1004</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1004<img src=""http://localhost/Subtext.Web/aggbug/1004.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + "<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + "<guid>http://localhost/Subtext.Web/whatever/1004</guid>" + Environment.NewLine + indent(3) + "<pubDate>Mon, 14 Jul 2003 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + "<comments>http://localhost/Subtext.Web/whatever/1004#feedback</comments>" + Environment.NewLine + indent(3) + "<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1004.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + "</item>" + Environment.NewLine + indent(2) + "<item>" + Environment.NewLine + indent(3) + "<title>Title of 1003.</title>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever/1003</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1003<img src=""http://localhost/Subtext.Web/aggbug/1003.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + "<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + "<guid>http://localhost/Subtext.Web/whatever/1003</guid>" + Environment.NewLine + indent(3) + "<pubDate>Tue, 16 Oct 1979 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + "<comments>http://localhost/Subtext.Web/whatever/1003#feedback</comments>" + Environment.NewLine + indent(3) + "<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1003.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + "</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + "<title>Title of 1002.</title>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/whatever/1002</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1002<img src=""http://localhost/Subtext.Web/aggbug/1002.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + "<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + "<guid>http://localhost/Subtext.Web/whatever/1002</guid>" + Environment.NewLine + indent(3) + "<pubDate>Fri, 25 Jun 1976 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + "<comments>http://localhost/Subtext.Web/whatever/1002#feedback</comments>" + Environment.NewLine + indent(3) + "<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1002.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + "</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + "<title>Title of 1001.</title>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/whatever/1001</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1001<img src=""http://localhost/Subtext.Web/aggbug/1001.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + "<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + "<guid>http://localhost/Subtext.Web/whatever/1001</guid>" + Environment.NewLine + indent(3) + "<pubDate>Sun, 23 Feb 1975 08:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + "<comments>http://localhost/Subtext.Web/whatever/1001#feedback</comments>" + Environment.NewLine + indent(3) + "<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1001.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + "</item>" + Environment.NewLine + indent() + "</channel>" + Environment.NewLine + "</rss>"; expected = string.Format(expected, VersionInfo.VersionDisplayText); UnitTestHelper.AssertStringsEqualCharacterByCharacter(expected, writer.Xml); }
public void EditBlog(Blog blogToEdit) { blogToEdit.LastEditedTime = DateTime.Now; blogRepository.Update(blogToEdit); SaveBlog(); }
public void SetGlobalFilterQuery() { // Doesn't appear to be a way to test this except to try it out... try { _connection.Open(); var options = new DbContextOptionsBuilder() .UseSqlite(_connection) .Options; var tenant1 = new TenantInfo { Id = "abc", Identifier = "abc", Name = "abc", ConnectionString = "DataSource=testDb.db" }; using (var db = new TestBlogDbContext(tenant1, options)) { db.Database.EnsureDeleted(); db.Database.EnsureCreated(); var blog1 = new Blog { Title = "abc" }; db.Blogs.Add(blog1); var post1 = new Post { Title = "post in abc", Blog = blog1 }; db.Posts.Add(post1); db.SaveChanges(); } var tenant2 = new TenantInfo { Id = "123", Identifier = "123", Name = "123", ConnectionString = "DataSource=testDb.db" }; using (var db = new TestBlogDbContext(tenant2, options)) { var blog1 = new Blog { Title = "123" }; db.Blogs.Add(blog1); var post1 = new Post { Title = "post in 123", Blog = blog1 }; db.Posts.Add(post1); db.SaveChanges(); } int postCount1 = 0; int postCount2 = 0; using (var db = new TestBlogDbContext(tenant1, options)) { postCount1 = db.Posts.Count(); postCount2 = db.Posts.IgnoreQueryFilters().Count(); } Assert.Equal(1, postCount1); Assert.Equal(2, postCount2); } finally { _connection.Close(); } }
/// <summary> /// Locates a Post object and specifies the result as the page's DataContext /// </summary> private void LoadBlog() { Blog currentBlog = App.MasterViewModel.CurrentBlog; BlogName.Text = string.IsNullOrEmpty(currentBlog.BlogNameUpper) ? "" : currentBlog.BlogNameUpper; bool isSharingPhoto = (App.MasterViewModel.SharingPhotoToken != null); if (null != App.MasterViewModel.CurrentPostListItem && !isSharingPhoto) { string postId = App.MasterViewModel.CurrentPostListItem.PostId; if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1) { // Post is a local draft this.isEditingLocalDraft = true; DataContext = App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex]; App.MasterViewModel.CurrentPost = App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex]; setStatus(); initPostFormatUI(App.MasterViewModel.CurrentPost.PostFormat); //update the Media UI List <Media> unavaiblePictures = new List <Media>(); foreach (Media currentMedia in App.MasterViewModel.CurrentPost.Media) { using (Stream stream = currentMedia.getImageStream()) { if (stream == null) { unavaiblePictures.Add(currentMedia); continue; } try { BitmapImage image = new BitmapImage(); image.SetSource(stream); imageWrapPanel.Children.Add(BuildTappableImageElement(image, currentMedia)); } catch (Exception) { } } } if (unavaiblePictures.Count > 0) { MessageBoxResult result = MessageBox.Show("Can't read a picture attached to this draft, please try to load the draft later.", "Error", MessageBoxButton.OK); foreach (Media m in unavaiblePictures) { App.MasterViewModel.CurrentPost.Media.Remove(m); } } } else { Post post = App.MasterViewModel.CurrentPost; DataContext = post; setStatus(); initPostFormatUI(post.PostFormat); if (!string.IsNullOrWhiteSpace(post.MtKeyWords)) { tagsTextBox.Text = post.MtKeyWords; } } } else { //New post Post post = new Post(); App.MasterViewModel.CurrentPost = post; post.DateCreated = DateTime.Now; post.DateCreatedGMT = DateTime.Now.ToUniversalTime(); DataContext = post; initPostFormatUI("standard"); post.PostStatus = "publish"; setStatus(); /*postTimePicker.Value = post.DateCreated; * postDatePicker.Value = post.DateCreated;*/ if (isSharingPhoto) { MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(App.MasterViewModel.SharingPhotoToken); using (Stream pictureStream = picture.GetImage()) AddNewMediaStream(pictureStream, picture.Name); ; // clear the photo token so we don't try to add it to another post App.MasterViewModel.SharingPhotoToken = null; // blog selection page will be in the backstack, but if the user hits Back they should leave the app // and return to the photo that they were sharing (e.g., so they can share it on another service) NavigationService.RemoveBackEntry(); } } this.ToggleGalleryControlsVisibility(); }
public static void Initialize(BloggingContext context) { context.Database.EnsureCreated(); // Seed the database if (context.Blogs.Any()) { return; } var blog1 = new Blog() { Name = "API", Rating = 5, Url = "/blogs/api" }; context.Blogs.Add(blog1); var blog2 = new Blog() { Name = "Angular", Rating = 5, Url = "/blogs/angular" }; context.Blogs.Add(blog2); var blog3 = new Blog() { Name = ".NET Core", Rating = 5, Url = "/blogs/dotnet" }; context.Blogs.Add(blog3); context.SaveChanges(); var post1 = new Post() { Blog = blog1, Title = "Awesome API", Content = "APIs are awesome" }; context.Posts.Add(post1); var post2 = new Post() { Blog = blog1, Title = "Love APIs", Content = "Let's build more APIs" }; context.Posts.Add(post2); var post3 = new Post() { Blog = blog1, Title = ".NET Core WebApi", Content = "Can be hosted on Azure" }; context.Posts.Add(post3); context.SaveChanges(); var image1 = new Image() { Post = post1, Title = "Title of Image 1", Url = "Url of Image 1" }; context.Images.Add(image1); var image2 = new Image() { Post = post1, Title = "Title of Image 2", Url = "Url of Image 2" }; context.Images.Add(image2); var image3 = new Image() { Post = post1, Title = "Title of Image 3", Url = "Url of Image 3" }; context.Images.Add(image3); context.SaveChanges(); }
public IActionResult BlogDetails(int matt) { Blog blog = db.Blog.SingleOrDefault(p => p.MaTt == matt); return(View(blog)); }
public virtual void ModifyAndThrowException2(Blog blog, String newName) { blog.Name = newName; throw new Exception("Doh!"); }
public void Setup() { blog = BloggerInitializer.GetBlogs().First(); article = BloggerInitializer.GetChsakellsArticles().First(); formatter = new ArticleFormatter(); }
public void Remove(Blog blog) { throw new NotImplementedException(); }
public void Add(Blog blog) { throw new NotImplementedException(); }
protected override void RenderContents(HtmlTextWriter output) { DataSet dsBlogs = null; // Check for Featured Post, if it exists grab one less post to keep the count correct if (blogConfig.FeaturedPostId == 0) { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, pageSize, out totalPages); } else { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, (pageSize - 1), out totalPages); } DataRow featuredRow = dsBlogs.Tables["Posts"].NewRow(); if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { using (IDataReader reader = Blog.GetSingleBlog(blogConfig.FeaturedPostId)) { while (reader.Read()) { featuredRow["ItemID"] = Convert.ToInt32(reader["ItemID"]); featuredRow["ModuleID"] = Convert.ToInt32(reader["ModuleID"]); featuredRow["BlogGuid"] = reader["BlogGuid"].ToString(); featuredRow["CreatedDate"] = Convert.ToDateTime(reader["CreatedDate"]); featuredRow["Heading"] = reader["Heading"].ToString(); featuredRow["SubTitle"] = reader["SubTitle"].ToString(); featuredRow["StartDate"] = Convert.ToDateTime(reader["StartDate"]); featuredRow["Description"] = reader["Description"].ToString(); featuredRow["Abstract"] = reader["Abstract"].ToString(); featuredRow["ItemUrl"] = reader["ItemUrl"].ToString(); featuredRow["Location"] = reader["Location"].ToString(); featuredRow["MetaKeywords"] = reader["MetaKeywords"].ToString(); featuredRow["MetaDescription"] = reader["MetaDescription"].ToString(); featuredRow["LastModUtc"] = Convert.ToDateTime(reader["LastModUtc"]); featuredRow["IsPublished"] = true; featuredRow["IncludeInFeed"] = Convert.ToBoolean(reader["IncludeInFeed"]); featuredRow["CommentCount"] = Convert.ToInt32(reader["CommentCount"]); featuredRow["CommentCount"] = 0; featuredRow["UserID"] = Convert.ToInt32(reader["UserID"]); featuredRow["UserID"] = -1; featuredRow["Name"] = reader["Name"].ToString(); featuredRow["FirstName"] = reader["FirstName"].ToString(); featuredRow["LastName"] = reader["LastName"].ToString(); featuredRow["LoginName"] = reader["LoginName"].ToString(); featuredRow["Email"] = reader["Email"].ToString(); featuredRow["AvatarUrl"] = reader["AvatarUrl"].ToString(); featuredRow["AuthorBio"] = reader["AuthorBio"].ToString(); featuredRow["AllowCommentsForDays"] = Convert.ToInt32(reader["AllowCommentsForDays"]); if (reader["ShowAuthorName"] != DBNull.Value) { featuredRow["ShowAuthorName"] = Convert.ToBoolean(reader["ShowAuthorName"]); } else { featuredRow["ShowAuthorName"] = true; } if (reader["ShowAuthorAvatar"] != DBNull.Value) { featuredRow["ShowAuthorAvatar"] = Convert.ToBoolean(reader["ShowAuthorAvatar"]); } else { featuredRow["ShowAuthorAvatar"] = true; } if (reader["ShowAuthorBio"] != DBNull.Value) { featuredRow["ShowAuthorBio"] = Convert.ToBoolean(reader["ShowAuthorBio"]); } else { featuredRow["ShowAuthorBio"] = true; } if (reader["UseBingMap"] != DBNull.Value) { featuredRow["UseBingMap"] = Convert.ToBoolean(reader["UseBingMap"]); } else { featuredRow["UseBingMap"] = false; } featuredRow["MapHeight"] = reader["MapHeight"].ToString(); featuredRow["MapWidth"] = reader["MapWidth"].ToString(); featuredRow["MapType"] = reader["MapType"].ToString(); if (reader["MapZoom"] != DBNull.Value) { featuredRow["MapZoom"] = Convert.ToInt32(reader["MapZoom"]); } else { featuredRow["MapZoom"] = 13; } if (reader["ShowMapOptions"] != DBNull.Value) { featuredRow["ShowMapOptions"] = Convert.ToBoolean(reader["ShowMapOptions"]); } else { featuredRow["ShowMapOptions"] = false; } if (reader["ShowZoomTool"] != DBNull.Value) { featuredRow["ShowZoomTool"] = Convert.ToBoolean(reader["ShowZoomTool"]); } else { featuredRow["ShowZoomTool"] = false; } if (reader["ShowLocationInfo"] != DBNull.Value) { featuredRow["ShowLocationInfo"] = Convert.ToBoolean(reader["ShowLocationInfo"]); } else { featuredRow["ShowLocationInfo"] = false; } if (reader["UseDrivingDirections"] != DBNull.Value) { featuredRow["UseDrivingDirections"] = Convert.ToBoolean(reader["UseDrivingDirections"]); } else { featuredRow["UseDrivingDirections"] = false; } if (reader["ShowDownloadLink"] != DBNull.Value) { featuredRow["ShowDownloadLink"] = Convert.ToBoolean(reader["ShowDownloadLink"]); } else { featuredRow["ShowDownloadLink"] = false; } featuredRow["HeadlineImageUrl"] = reader["HeadlineImageUrl"].ToString(); if (reader["IncludeImageInExcerpt"] != DBNull.Value) { featuredRow["IncludeImageInExcerpt"] = Convert.ToBoolean(reader["IncludeImageInExcerpt"]); } else { featuredRow["IncludeImageInExcerpt"] = true; } if (reader["IncludeImageInPost"] != DBNull.Value) { featuredRow["IncludeImageInPost"] = Convert.ToBoolean(reader["IncludeImageInPost"]); } else { featuredRow["IncludeImageInPost"] = true; } } } } //look for featured post in datable DataRow found = dsBlogs.Tables["Posts"].Rows.Find(blogConfig.FeaturedPostId); if (found != null) { //remove featured post from datatable so we can insert it at the top if we're on "page" number 1 dsBlogs.Tables["Posts"].Rows.Remove(found); } if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { //insert the featured post into the datatable at the top //we only want to do this if the current "page" is number 1, don't want the featured post on other pages. dsBlogs.Tables["Posts"].Rows.InsertAt(featuredRow, 0); } List <PageModule> pageModules = PageModule.GetPageModulesByModule(config.BlogModuleId); string blogPageUrl = string.Empty; if (pageModules.Count > 0) { blogPageUrl = pageModules[0].PageUrl; } List <BlogPostModel> models = new List <BlogPostModel>(); foreach (DataRow postRow in dsBlogs.Tables["posts"].Rows) { BlogPostModel model = new BlogPostModel(); if (useFriendlyUrls && (postRow["ItemUrl"].ToString().Length > 0)) { model.ItemUrl = postRow["ItemUrl"].ToString().Replace("~", string.Empty); } else { model.ItemUrl = postRow["ItemID"].ToString() + "&mid=" + postRow["ModuleID"].ToString(); } if (blogConfig.FeaturedPostId == Convert.ToInt32(postRow["ItemID"]) && pageNumber == 1) { model.FeaturedPost = true; } else { model.FeaturedPost = false; } model.Title = postRow["Heading"].ToString(); model.SubTitle = postRow["SubTitle"].ToString(); model.Body = postRow["Description"].ToString(); model.AuthorAvatar = postRow["AvatarUrl"].ToString(); model.AuthorDisplayName = postRow["Name"].ToString(); model.AuthorFirstName = postRow["FirstName"].ToString(); model.AuthorLastName = postRow["LastName"].ToString(); model.AuthorBio = postRow["AuthorBio"].ToString(); model.Excerpt = postRow["Abstract"].ToString(); model.PostDate = Convert.ToDateTime(postRow["StartDate"].ToString()); model.HeadlineImageUrl = postRow["HeadlineImageUrl"].ToString(); model.CommentCount = Convert.ToInt32(postRow["CommentCount"]); model.AllowCommentsForDays = Convert.ToInt32(postRow["AllowCommentsForDays"]); model.ShowAuthorName = Convert.ToBoolean(postRow["ShowAuthorName"]); model.ShowAuthorAvatar = Convert.ToBoolean(postRow["ShowAuthorAvatar"]); model.ShowAuthorBio = Convert.ToBoolean(postRow["ShowAuthorBio"]); model.AuthorUserId = Convert.ToInt32(postRow["UserID"]); models.Add(model); } PostListModel postListObject = new PostListModel(); postListObject.ModuleTitle = module == null ? "" : module.ModuleTitle; postListObject.ModulePageUrl = Page.ResolveUrl(blogPageUrl); postListObject.Posts = models; string text = string.Empty; try { text = RazorBridge.RenderPartialToString(config.Layout, postListObject, "Blog"); } catch (System.Web.HttpException ex) { log.ErrorFormat( "chosen layout ({0}) for _BlogPostList was not found in skin {1}. perhaps it is in a different skin. Error was: {2}", config.Layout, SiteUtils.GetSkinBaseUrl(true, Page), ex ); text = RazorBridge.RenderPartialToString("_BlogPostList", postListObject, "Blog"); } output.Write(text); }
public async Task <IActionResult> Update(int?id, Blog blog, string[] Moderators, int[] Categories) { object[] obj = await Helpers.Helper.CreateVM(_context, _userManager); ViewBag.Categories = obj[0]; ViewBag.Moderators = obj[1]; if (id == null) { return(NotFound()); } Blog blogDb = await _context.Blogs.Where(b => !b.IsDeleted && b.Id == id).FirstOrDefaultAsync(); _context.IncludeModeratorsBlog(false); _context.IncludeCategoryBlog(false); if (blogDb == null) { return(NotFound()); } if (!ModelState.IsValid) { return(View(blogDb)); } if (Helpers.Helper.CheckLengthArray(Categories, ModelState)) { return(View(blogDb)); } if (Helpers.Helper.CheckLengthArray(Moderators, ModelState)) { return(View(blogDb)); } if (blog.Name != blogDb.Name) { bool IsExist = _context.Blogs.Where(b => !b.IsDeleted).Any(b => b.Name.ToLower() == blog.Name.ToLower()); if (IsExist) { ModelState.AddModelError("Name", "This course name already exist!!!"); return(View(blogDb)); } } if (blog.Photo != null) { if (!blog.Photo.PhotoValidate(ModelState)) { return(View(blogDb)); } string folder = Path.Combine("site", "img", "blog"); string fileName = await blog.Photo.SaveImage(_env.WebRootPath, folder); blogDb.Image = fileName; } List <BlogCategory> blogCategories = new List <BlogCategory>(); foreach (int categoryId in Categories) { blogCategories.Add(new BlogCategory { CategoryId = categoryId, BlogId = blog.Id, Activeted = blog.Activeted }); } List <BlogModerator> blogModerators = new List <BlogModerator>(); foreach (string moderatorId in Moderators) { blogModerators.Add(new BlogModerator { ModeratorId = moderatorId, BlogId = blog.Id, Activeted = blog.Activeted }); } blogDb.Name = blog.Name; blogDb.Description = blog.Description; blogDb.BlogCategories = blogCategories; blogDb.BlogModerators = blogModerators; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public void CreateBlog(Blog blog) { blogRepository.Add(blog); SaveBlog(); }
public SingleBlogPostResponse(Blog blog) { BlogPost = new BlogResponse(blog); }
public async Task <IActionResult> Create(Blog blog, string[] Moderators, int[] Categories) { object[] obj = await Helpers.Helper.CreateVM(_context, _userManager); ViewBag.Categories = obj[0]; ViewBag.Moderators = obj[1]; if (Helpers.Helper.CheckLengthArray(Categories, ModelState)) { return(View(blog)); } if (Helpers.Helper.CheckLengthArray(Moderators, ModelState)) { return(View(blog)); } if (!ModelState.IsValid) { return(View(blog)); } bool IsExist = _context.Blogs.Where(b => !b.IsDeleted).Any(b => b.Name.ToLower() == blog.Name.ToLower()); if (IsExist) { ModelState.AddModelError("Name", "This course name already exist!!!"); return(View(blog)); } if (!blog.Photo.PhotoValidate(ModelState)) { return(View(blog)); } string folder = Path.Combine("site", "img", "blog"); string fileName = await blog.Photo.SaveImage(_env.WebRootPath, folder); blog.Image = fileName; List <BlogCategory> blogCategories = new List <BlogCategory>(); foreach (int id in Categories) { blogCategories.Add(new BlogCategory { CategoryId = id, BlogId = blog.Id, Activeted = blog.Activeted }); } List <BlogModerator> blogModerators = new List <BlogModerator>(); foreach (string id in Moderators) { blogModerators.Add(new BlogModerator { ModeratorId = id, BlogId = blog.Id, Activeted = blog.Activeted }); } blog.BlogCategories = blogCategories; blog.BlogModerators = blogModerators; blog.IsDeleted = false; blog.Created_at = DateTime.Now; await _context.Blogs.AddAsync(blog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public void RssWriterProducesValidFeed() { UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "", "Subtext.Web"); var blogInfo = new Blog(); BlogRequest.Current.Blog = blogInfo; blogInfo.Host = "localhost"; blogInfo.Title = "My Blog Is Better Than Yours"; blogInfo.Email = "*****@*****.**"; blogInfo.RFC3229DeltaEncodingEnabled = true; blogInfo.TimeZoneId = TimeZonesTest.PacificTimeZoneId; blogInfo.ShowEmailAddressInRss = true; blogInfo.TrackbacksEnabled = true; HttpContext.Current.Items.Add("BlogInfo-", blogInfo); var entries = new List <Entry>(CreateSomeEntries()); entries[0].Categories.AddRange(new[] { "Category1", "Category2" }); entries[0].Email = "*****@*****.**"; entries[2].Categories.Add("Category 3"); var enc = new Enclosure(); enc.Url = "http://perseus.franklins.net/hanselminutes_0107.mp3"; enc.Title = "<Digital Photography Explained (for Geeks) with Aaron Hockley/>"; enc.Size = 26707573; enc.MimeType = "audio/mp3"; enc.AddToFeed = true; entries[2].Enclosure = enc; var enc1 = new Enclosure(); enc1.Url = "http://perseus.franklins.net/hanselminutes_0107.mp3"; enc1.Title = "<Digital Photography Explained (for Geeks) with Aaron Hockley/>"; enc1.Size = 26707573; enc1.MimeType = "audio/mp3"; enc1.AddToFeed = false; entries[3].Enclosure = enc1; var subtextContext = new Mock <ISubtextContext>(); subtextContext.FakeSyndicationContext(blogInfo, "/", "Subtext.Web", null); Mock <BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper); urlHelper.Setup(u => u.BlogUrl()).Returns("/Subtext.Web/"); urlHelper.Setup(u => u.EntryUrl(It.IsAny <Entry>())).Returns <Entry>( e => "/Subtext.Web/whatever/" + e.Id + ".aspx"); var writer = new RssWriter(new StringWriter(), entries, NullValue.NullDateTime, false, subtextContext.Object); string expected = @"<rss version=""2.0"" " + @"xmlns:dc=""http://purl.org/dc/elements/1.1/"" " + @"xmlns:trackback=""http://madskills.com/public/xml/rss/module/trackback/"" " + @"xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" " + @"xmlns:slash=""http://purl.org/rss/1.0/modules/slash/"" " + @"xmlns:copyright=""http://blogs.law.harvard.edu/tech/rss"" " + @"xmlns:image=""http://purl.org/rss/1.0/modules/image/"">" + Environment.NewLine + indent() + @"<channel>" + Environment.NewLine + indent(2) + @"<title>My Blog Is Better Than Yours</title>" + Environment.NewLine + indent(2) + @"<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(2) + @"<description />" + Environment.NewLine + indent(2) + @"<language>en-US</language>" + Environment.NewLine + indent(2) + @"<copyright>Subtext Weblog</copyright>" + Environment.NewLine + indent(2) + @"<managingEditor>[email protected]</managingEditor>" + Environment.NewLine + indent(2) + @"<generator>{0}</generator>" + Environment.NewLine + indent(2) + @"<image>" + Environment.NewLine + indent(3) + @"<title>My Blog Is Better Than Yours</title>" + Environment.NewLine + indent(3) + @"<url>http://localhost/Subtext.Web/images/RSS2Image.gif</url>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(3) + @"<width>77</width>" + Environment.NewLine + indent(3) + @"<height>60</height>" + Environment.NewLine + indent(2) + @"</image>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + @"<title>Title of 1001.</title>" + Environment.NewLine + indent(3) + @"<category>Category1</category>" + Environment.NewLine + indent(3) + @"<category>Category2</category>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever/1001.aspx</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1001<img src=""http://localhost/Subtext.Web/aggbug/1001.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever/1001.aspx</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Sun, 23 Feb 1975 08:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever/1001.aspx#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1001.aspx</wfw:commentRss>" + Environment.NewLine + indent(3) + @"<trackback:ping>http://localhost/Subtext.Web/services/trackbacks/1001.aspx</trackback:ping>" + Environment.NewLine + indent(2) + @"</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + @"<title>Title of 1002.</title>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever/1002.aspx</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1002<img src=""http://localhost/Subtext.Web/aggbug/1002.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever/1002.aspx</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Fri, 25 Jun 1976 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever/1002.aspx#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1002.aspx</wfw:commentRss>" + Environment.NewLine + indent(3) + @"<trackback:ping>http://localhost/Subtext.Web/services/trackbacks/1002.aspx</trackback:ping>" + Environment.NewLine + indent(2) + @"</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + @"<title>Title of 1003.</title>" + Environment.NewLine + indent(3) + @"<category>Category 3</category>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever/1003.aspx</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1003<img src=""http://localhost/Subtext.Web/aggbug/1003.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever/1003.aspx</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Tue, 16 Oct 1979 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever/1003.aspx#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1003.aspx</wfw:commentRss>" + Environment.NewLine + indent(3) + @"<trackback:ping>http://localhost/Subtext.Web/services/trackbacks/1003.aspx</trackback:ping>" + Environment.NewLine + indent(3) + @"<enclosure url=""http://perseus.franklins.net/hanselminutes_0107.mp3"" length=""26707573"" type=""audio/mp3"" />" + Environment.NewLine + indent(2) + @"</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + @"<title>Title of 1004.</title>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever/1004.aspx</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1004<img src=""http://localhost/Subtext.Web/aggbug/1004.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever/1004.aspx</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Mon, 14 Jul 2003 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever/1004.aspx#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1004.aspx</wfw:commentRss>" + Environment.NewLine + indent(3) + @"<trackback:ping>http://localhost/Subtext.Web/services/trackbacks/1004.aspx</trackback:ping>" + Environment.NewLine + indent(2) + @"</item>" + Environment.NewLine + indent() + @"</channel>" + Environment.NewLine + @"</rss>"; expected = string.Format(expected, VersionInfo.VersionDisplayText); UnitTestHelper.AssertStringsEqualCharacterByCharacter(expected, writer.Xml); }
private string BuildFileNameCore(string url, string blogName, DateTime date, int timestamp, int index, string type, string id, List <string> tags, string slug, string title, string rebloggedFromName, string rebloggedRootName, string reblog_key) { /* * Replaced are: * %f original filename (default) * %b blog name * %d post date (yyyyMMdd) * %e post date and time (yyyyMMddHHmmss) * %g post date in GMT (yyyyMMdd) * %h post date and time in GMT (yyyyMMddHHmmss) * %u post timestamp (number) * %o blog name of reblog origin * %p post title (shorted if needed…) * %i post id * %n image index (of photo sets) * %t for all tags (cute+cats,big+dogs) * %r for reblog ("" / "reblog") * %s slug (last part of a post's url) * %k reblog-key * Tokens to make filenames unique: * %x "_{number}" ({number}: 2..n) * %y " ({number})" ({number}: 2..n) */ url = url.IndexOf('?') > 0 ? url.Substring(0, url.IndexOf('?')) : url; string extension = Path.GetExtension(FileName(url)); if (extension.ToLower() == ".gifv") { extension = ".gif"; } else if (extension.ToLower() == ".pnj") { extension += ".png"; } string filename = Blog.FilenameTemplate + extension; if (ContainsCI(filename, "%f")) { filename = ReplaceCI(filename, "%f", Path.GetFileNameWithoutExtension(FileName(url))); } if (ContainsCI(filename, "%d")) { filename = ReplaceCI(filename, "%d", date.ToString("yyyyMMdd")); } if (ContainsCI(filename, "%e")) { filename = ReplaceCI(filename, "%e", date.ToString("yyyyMMddHHmmss")); } if (ContainsCI(filename, "%g")) { filename = ReplaceCI(filename, "%g", date.ToUniversalTime().ToString("yyyyMMdd")); } if (ContainsCI(filename, "%h")) { filename = ReplaceCI(filename, "%h", date.ToUniversalTime().ToString("yyyyMMddHHmmss")); } if (ContainsCI(filename, "%u")) { filename = ReplaceCI(filename, "%u", timestamp.ToString()); } if (ContainsCI(filename, "%b")) { filename = ReplaceCI(filename, "%b", blogName); } if (ContainsCI(filename, "%i")) { if (type == "photo" && Blog.GroupPhotoSets && index != -1) { id = $"{id}_{index}"; } filename = ReplaceCI(filename, "%i", id); } else if (type == "photo" && Blog.GroupPhotoSets && index != -1) { filename = $"{id}_{index}_{filename}"; } if (ContainsCI(filename, "%n")) { if (type != "photo" || index == -1) { string charBefore = ""; string charAfter = ""; if (filename.IndexOf("%n", StringComparison.OrdinalIgnoreCase) > 0) { charBefore = filename.Substring(filename.IndexOf("%n", StringComparison.OrdinalIgnoreCase) - 1, 1); } if (filename.IndexOf("%n", StringComparison.OrdinalIgnoreCase) < filename.Length - 2) { charAfter = filename.Substring(filename.IndexOf("%n", StringComparison.OrdinalIgnoreCase) + 2, 1); } if (charBefore == charAfter) { filename = filename.Remove(filename.IndexOf("%n", StringComparison.OrdinalIgnoreCase) - 1, 1); } filename = ReplaceCI(filename, "%n", ""); } else { filename = ReplaceCI(filename, "%n", index.ToString()); } } if (ContainsCI(filename, "%t")) { filename = ReplaceCI(filename, "%t", string.Join(",", tags).Replace(" ", "+")); } if (ContainsCI(filename, "%r")) { if (rebloggedFromName.Length == 0 && filename.IndexOf("%r", StringComparison.OrdinalIgnoreCase) > 0 && filename.IndexOf("%r", StringComparison.OrdinalIgnoreCase) < filename.Length - 2 && filename.Substring(filename.IndexOf("%r", StringComparison.OrdinalIgnoreCase) - 1, 1) == filename.Substring(filename.IndexOf("%r", StringComparison.OrdinalIgnoreCase) + 2, 1)) { filename = filename.Remove(filename.IndexOf("%r", StringComparison.OrdinalIgnoreCase), 3); } filename = ReplaceCI(filename, "%r", (rebloggedFromName.Length == 0 ? "" : "reblog")); } if (ContainsCI(filename, "%o")) { filename = ReplaceCI(filename, "%o", rebloggedRootName); } if (ContainsCI(filename, "%s")) { filename = ReplaceCI(filename, "%s", slug); } if (ContainsCI(filename, "%k")) { filename = ReplaceCI(filename, "%k", reblog_key); } int neededChars = 0; if (ContainsCI(filename, "%x")) { neededChars = 6; Downloader.AppendTemplate = "_<0>"; filename = ReplaceCI(filename, "%x", ""); } if (ContainsCI(filename, "%y")) { neededChars = 8; Downloader.AppendTemplate = " (<0>)"; filename = ReplaceCI(filename, "%y", ""); } if (ContainsCI(filename, "%p")) { string _title = title; if (!ShellService.IsLongPathSupported) { string filepath = Path.Combine(Blog.DownloadLocation(), filename); // 260 (max path minus NULL) - current filename length + 2 chars (%p) - chars for numbering int charactersLeft = 259 - filepath.Length + 2 - neededChars; if (charactersLeft < 0) { throw new PathTooLongException($"{Blog.Name}: filename for post id {id} is too long"); } if (charactersLeft < _title.Length) { _title = _title.Substring(0, charactersLeft - 1) + "…"; } } filename = ReplaceCI(filename, "%p", _title); } else if (!ShellService.IsLongPathSupported) { string filepath = Path.Combine(Blog.DownloadLocation(), filename); // 260 (max path minus NULL) - current filename length - chars for numbering int charactersLeft = 259 - filepath.Length - neededChars; if (charactersLeft < 0) { throw new PathTooLongException($"{Blog.Name}: filename for post id {id} is too long"); } } return(Sanitize(filename)); }
public void RssWriterHandlesRFC3229DeltaEncoding() { UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "", "Subtext.Web"); var blogInfo = new Blog(); BlogRequest.Current.Blog = blogInfo; blogInfo.Host = "localhost"; blogInfo.Subfolder = ""; blogInfo.Email = "*****@*****.**"; blogInfo.RFC3229DeltaEncodingEnabled = true; blogInfo.TimeZoneId = TimeZonesTest.PacificTimeZoneId; HttpContext.Current.Items.Add("BlogInfo-", blogInfo); var entries = new List <Entry>(CreateSomeEntriesDescending()); var subtextContext = new Mock <ISubtextContext>(); subtextContext.FakeSyndicationContext(blogInfo, "/", "Subtext.Web", null); Mock <BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper); urlHelper.Setup(u => u.BlogUrl()).Returns("/Subtext.Web/"); urlHelper.Setup(u => u.EntryUrl(It.IsAny <Entry>())).Returns("/Subtext.Web/whatever"); // Tell the write we already received 1002 published 6/25/1976. var writer = new RssWriter(new StringWriter(), entries, DateTime.ParseExact("06/25/1976", "MM/dd/yyyy", CultureInfo.InvariantCulture), true, subtextContext.Object); // We only expect 1003 and 1004 string expected = @"<rss version=""2.0"" xmlns:dc=""http://purl.org/dc/elements/1.1/"" xmlns:trackback=""http://madskills.com/public/xml/rss/module/trackback/"" xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" xmlns:slash=""http://purl.org/rss/1.0/modules/slash/"" xmlns:copyright=""http://blogs.law.harvard.edu/tech/rss"" xmlns:image=""http://purl.org/rss/1.0/modules/image/"">" + Environment.NewLine + indent() + "<channel>" + Environment.NewLine + indent(2) + "<title />" + Environment.NewLine + indent(2) + "<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(2) + "<description />" + Environment.NewLine + indent(2) + "<language>en-US</language>" + Environment.NewLine + indent(2) + "<copyright>Subtext Weblog</copyright>" + Environment.NewLine + indent(2) + "<generator>{0}</generator>" + Environment.NewLine + indent(2) + "<image>" + Environment.NewLine + indent(3) + "<title />" + Environment.NewLine + indent(3) + "<url>http://localhost/Subtext.Web/images/RSS2Image.gif</url>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/Default.aspx</link>" + Environment.NewLine + indent(3) + "<width>77</width>" + Environment.NewLine + indent(3) + "<height>60</height>" + Environment.NewLine + indent(2) + "</image>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + @"<title>Title of 1004.</title>" + Environment.NewLine + indent(3) + @"<link>http://localhost/Subtext.Web/whatever</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1004<img src=""http://localhost/Subtext.Web/aggbug/1004.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Mon, 14 Jul 2003 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1004.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + @"</item>" + Environment.NewLine + indent(2) + @"<item>" + Environment.NewLine + indent(3) + "<title>Title of 1003.</title>" + Environment.NewLine + indent(3) + "<link>http://localhost/Subtext.Web/whatever</link>" + Environment.NewLine + indent(3) + @"<description>Body of 1003<img src=""http://localhost/Subtext.Web/aggbug/1003.aspx"" width=""1"" height=""1"" /></description>" + Environment.NewLine + indent(3) + @"<dc:creator>Phil Haack</dc:creator>" + Environment.NewLine + indent(3) + @"<guid>http://localhost/Subtext.Web/whatever</guid>" + Environment.NewLine + indent(3) + @"<pubDate>Tue, 16 Oct 1979 07:00:00 GMT</pubDate>" + Environment.NewLine + indent(3) + @"<comments>http://localhost/Subtext.Web/whatever#feedback</comments>" + Environment.NewLine + indent(3) + @"<wfw:commentRss>http://localhost/Subtext.Web/comments/commentRss/1003.aspx</wfw:commentRss>" + Environment.NewLine + indent(2) + "</item>" + Environment.NewLine + indent() + "</channel>" + Environment.NewLine + "</rss>"; expected = string.Format(expected, VersionInfo.VersionDisplayText); Assert.AreEqual(expected, writer.Xml); Assert.AreEqual(DateTime.ParseExact("06/25/1976", "MM/dd/yyyy", CultureInfo.InvariantCulture), writer.DateLastViewedFeedItemPublishedUtc, "The Item ID Last Viewed (according to If-None-Since is wrong."); Assert.AreEqual(DateTime.ParseExact("07/14/2003", "MM/dd/yyyy", CultureInfo.InvariantCulture), writer.LatestPublishDateUtc, "The Latest Feed Item ID sent to the client is wrong."); }
private static void Seed() { // Create random blogs. var numberOfBlogs = RandomData.GetInt(4, 8); for (var i = 1; i <= numberOfBlogs; i++) { var blog = new Blog { BlogId = i, Name = RandomData.GetTitleWords() }; Blogs.Add(blog); } // Create random people. var personNameGenerator = new PersonNameGenerator(); var numberOfPersons = RandomData.GetInt(16, 32); for (var i = 1; i <= numberOfPersons; i++) { var firstName = personNameGenerator.GenerateRandomFirstName(); var lastName = personNameGenerator.GenerateRandomLastName(); var twitter = String.Format("@{0}{1}", firstName.First(), lastName).ToLowerInvariant(); var person = new Person { PersonId = i, FirstName = firstName, LastName = lastName, Twitter = twitter }; People.Add(person); } // Create random articles. var numberOfArticles = RandomData.GetInt(8, 16); for (var i = 1; i <= numberOfArticles; i++) { var blogId = RandomData.GetLong(1, numberOfBlogs); var authorId = RandomData.GetLong(1, numberOfPersons); var article = new Article { BlogId = blogId, AuthorId = authorId, ArticleId = i, Title = RandomData.GetTitleWords(), Text = RandomData.GetParagraphs() }; Articles.Add(article); } // Create random comments. var numberOfComments = RandomData.GetInt(16, 32); for (var i = 1; i <= numberOfComments; i++) { var articleId = RandomData.GetLong(1, numberOfArticles); var authorId = RandomData.GetLong(1, numberOfPersons); var comment = new Comment { ArticleId = articleId, AuthorId = authorId, CommentId = i, Body = RandomData.GetSentence() }; Comments.Add(comment); } }
private void SavePost() { //Post post = DataContext as Post; //changed to CurrentPost so categories would save Post post = App.MasterViewModel.CurrentPost; Blog blog = App.MasterViewModel.CurrentBlog; if (post.HasMedia() && !post.IsLocalDraft()) { bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible && uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault(); post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled); } //make sure the post has the latest UI data--the Save button is a ToolbarButton //which doesn't force focus to change post.Title = titleTextBox.Text; post.MtKeyWords = tagsTextBox.Text; if (post.IsNew) { if (!post.IsLocalDraft()) { // Anything but local draft status gets uploaded UserSettings settings = new UserSettings(); if (settings.UseTaglineForNewPosts) { post.AddTagline(settings.Tagline); } NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post); rpc.PostType = ePostType.post; rpc.Completed += OnNewPostRPCCompleted; rpc.ExecuteAsync(); currentXmlRpcConnection = rpc; this.Focus(); ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges); } else { // Create or update a local draft if (App.MasterViewModel.CurrentPostListItem != null) { if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1) { App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex] = post; } } else { blog.LocalPostDrafts.Add(post); } // Exit post editor if the app was not lauched from the sharing feature. if (NavigationService.CanGoBack) { NavigationService.GoBack(); } else { throw new ApplicationShouldEndException(); } } } else { EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post); rpc.Completed += OnEditPostRPCCompleted; rpc.ExecuteAsync(); currentXmlRpcConnection = rpc; this.Focus(); ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges); } }
public ActionResult YeniBlog(Blog p) { c.Blogs.Add(p); c.SaveChanges(); return(RedirectToAction("Index")); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); Blog currentBlog = App.MasterViewModel.CurrentBlog; }
public async Task <int> Add(Blog blog) { return(await _unitOfWork.BlogRepository.Add(_mapper.Map <BlogEntity>(blog))); }
public async Task <ActionResult> Create(BlogEditModel model) { if (!ModelState.IsValid) { return(Json(this.GetModelStateError().GetError())); } var db = new TDContext(); var UserId = User.Identity.GetUserId(); if (db.Blogs.Any(x => x.FullName == model.FullName)) { return(Json(Js.Error(Global.BlogNameUsed))); } var lstSelect = await new TagBlogDB(db).FindOrCreate(model.TagBlogId); model.Content = await model.Content.GetValidHtml(); model.Summary = await model.Content.GetSummary(); model.LongSummary = await model.Content.GetSummary(500); model.Name = model.FullName.GetSafeName(); model.Id = new DBHelper().GetBlogId(db); model.UserId = UserId; var blog = new Blog(model); if (model.ParentId != null) { var parent = await db.Blogs.FindAsync(model.ParentId); if (parent != null) { blog.ParentId = parent.Id; foreach (var item in parent.BlogTags.Select(x => x.TagBlogId)) { if (!lstSelect.Contains(item)) { lstSelect.Add(item); } } } } foreach (var item in lstSelect) { blog.BlogTags.Add(new BlogTag(item, blog.Id)); } var gal = new GalleryDB(db).CreateBlog(blog); if (!string.IsNullOrEmpty(model.ImageData)) { var saveFile = await this.db.SaveImage(model.ImageData, "blogs"); if (!saveFile.OK) { return(Json(Js.Error(saveFile.Message))); } saveFile.Image.IsMain = true; gal.AppFiles.Add(saveFile.Image); } db.Blogs.Add(blog); var str = await db.SaveMessageAsync(); if (str.NotNull()) { return(Json(str.GetError())); } if (string.IsNullOrEmpty(model.ParentId)) { var parent = await db.Blogs.FindAsync(model.ParentId); if (parent != null) { blog.ParentId = parent.Id; var lstAdd = new List <string>(); foreach (var item in parent.BlogTags.Select(x => x.TagBlogId)) { if (!lstAdd.Contains(item) && !await db.BlogTags.AnyAsync(x => x.TagBlogId == item && x.BlogId == model.Id)) { db.BlogTags.Add(new BlogTag { BlogId = model.Id, TagBlogId = item, }); lstAdd.Add(item); } } } } return(Json(Js.SuccessRedirect(Global.BlogInserted, "/admin/blogs"))); }
public async Task UpdateBlogStatus(Blog blog) { _context.Blogs.Update(blog); await _context.SaveChangesAsync(); }
public void NestedMultipleOneToManyFetchingWorksTrackingEnabled() { // setup the factory var config = new CustomConfig(); var selectQuery = new SelectQuery <Blog>(new Mock <IProjectedSelectQueryExecutor>().Object).FetchMany(b => b.Posts) .ThenFetchMany(p => p.Tags) .ThenFetch(t => t.ElTag) .FetchMany(b => b.Posts) .ThenFetchMany(p => p.DeletedTags) .ThenFetch(t => t.ElTag) .FetchMany(p => p.Posts) .ThenFetch(p => p.Author) as SelectQuery <Blog>; var writer = new SelectWriter(new SqlServer2012Dialect(), config); var result = writer.GenerateSql(selectQuery, new AutoNamingDynamicParameters()); var mapper = new MultiCollectionMapperGenerator(config); var funcFac = mapper.GenerateMultiCollectionMapper <Blog>(result.FetchTree).Item1; // setup the scenario var blog1 = new Blog { BlogId = 1 }; var blog2 = new Blog { BlogId = 2 }; var post1 = new Post { PostId = 1 }; var post2 = new Post { PostId = 2 }; var post3 = new Post { PostId = 3 }; var posttag1 = new PostTag { PostTagId = 1 }; var posttag2 = new PostTag { PostTagId = 2 }; var posttag3 = new PostTag { PostTagId = 3 }; var tag1 = new Tag { TagId = 1 }; var tag2 = new Tag { TagId = 2 }; var tag3 = new Tag { TagId = 3 }; var tag4 = new Tag { TagId = 4 }; var delPostTag1 = new PostTag { PostTagId = 3 }; var delPostTag2 = new PostTag { PostTagId = 4 }; var delPostTag3 = new PostTag { PostTagId = 5 }; var author1 = new User { UserId = 1 }; var author2 = new User { UserId = 2 }; // act Blog currentRoot = null; IList <Blog> results = new List <Blog>(); var dict0 = new Dictionary <int, Post>(); var hashsetPair0 = new HashSet <Tuple <int, int> >(); var dict1 = new Dictionary <int, PostTag>(); var hashsetPair1 = new HashSet <Tuple <int, int> >(); var dict2 = new Dictionary <int, PostTag>(); var hashsetPair2 = new HashSet <Tuple <int, int> >(); var func = (Func <object[], Blog>)funcFac.DynamicInvoke(currentRoot, results, dict0, hashsetPair0, dict1, hashsetPair1, dict2, hashsetPair2); func(new object[] { blog1, post1, author1, null, null, posttag1, tag1 }); func(new object[] { blog1, post1, author1, null, null, posttag2, tag2 }); func(new object[] { blog1, post2, author2, delPostTag1, tag3, null, null }); func(new object[] { blog1, post2, author2, delPostTag2, tag4, null, null }); func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag1, tag1 }); func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag1, tag1 }); func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag1, tag1 }); func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag2, tag2 }); func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag2, tag2 }); func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag2, tag2 }); func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag3, tag3 }); func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag3, tag3 }); func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag3, tag3 }); Assert.True(((ITrackedEntity)results[0]).IsTrackingEnabled()); Assert.True(((ITrackedEntity)results[0].Posts[0]).IsTrackingEnabled()); Assert.True(((ITrackedEntity)results[0].Posts[0].Author).IsTrackingEnabled()); Assert.True(((ITrackedEntity)results[0].Posts[0].Tags[0]).IsTrackingEnabled()); Assert.True(((ITrackedEntity)results[0].Posts[0].Tags[0].ElTag).IsTrackingEnabled()); }
internal Blog Create(Blog newData) { return(_repo.Create(newData)); }