public static BlogPost ConvertPost(BloggerPostData post) { if (post == null) { throw new ArgumentNullException(nameof(post)); } var author = new BlogAuthor { ImageUrl = post.Author?.Image?.Url, Name = post.Author?.DisplayName, SourceId = post.Author?.Id, Url = post.Author?.Url }; // Properties set by BlogSyncServiceUpdatePostsHelper: BlavenId, UrlSlug var blogPost = new BlogPost { BlogAuthor = author, Content = post.Content, Hash = GetBlogPostHash(post), PublishedAt = post.Published, SourceId = post.Id, SourceUrl = post.Url, BlogPostTags = post.Labels?.Select(x => new BlogPostTag(x)).ToList() ?? new List<BlogPostTag>(), Title = post.Title, UpdatedAt = post.Updated }; return blogPost; }
public ActionResult DeleteConfirmed(int id) { BlogAuthor blogauthor = db.BlogAuthors.Single(b => b.AuthorID == id); db.BlogAuthors.DeleteObject(blogauthor); db.SaveChanges(); return(RedirectToAction("Index")); }
public void linkDeleteBlogAuthor_Command(object sender, CommandEventArgs e) { int id = int.Parse(e.CommandArgument.ToString()); BlogAuthor blogAuthor = SessionManager.CurrentSession.Load <BlogAuthor>(id); SessionManager.CurrentSession.Delete(blogAuthor); SessionManager.CurrentSession.Flush(); GetBlogAuthors(); }
public BlogAuthorClassACL(BlogAuthor instance) { // allow the author himself to see his membership information this.Add(new ACLAccount(instance.Account, DataOperation.Retreive)); // allow the blog owner to add/delete/view authors this.Add(new ACLAccount(instance.Blog.Account, DataOperation.All)); // allow everyone to get information about this BlogAuthor this.Add(new ACLEveryoneAllowRetrieve()); }
public async Task <IActionResult> Update(BlogAuthor blogAuthor) { if (blogAuthor == null) { return(NoContent()); } UserRepository.PrepareEntityForUpdate(User, blogAuthor); await BlogRepository.CreateOrUpdateAuthorAsync(blogAuthor, CancellationToken.None); return(Ok()); }
public ActionResult Edit(BlogAuthor blogauthor) { if (ModelState.IsValid) { db.BlogAuthors.Attach(blogauthor); db.ObjectStateManager.ChangeObjectState(blogauthor, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blogauthor)); }
public ActionResult Create(BlogAuthor blogauthor) { if (ModelState.IsValid) { db.BlogAuthors.AddObject(blogauthor); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blogauthor)); }
public void createBlogAuthor_Click(object sender, EventArgs e) { IdentityServiceMembershipUser user = (IdentityServiceMembershipUser)Membership.GetUser(); Blog blog = SessionManager.CurrentSession.Load <Blog>(Int32.Parse(Request["id"])); BlogAuthor author = new BlogAuthor(); author.Account = SessionManager.CurrentSession.Load <Account>(Int32.Parse(listAccounts.SelectedValue)); author.Blog = blog; SessionManager.CurrentSession.Save(author); SessionManager.CurrentSession.Flush(); GetBlogAuthors(); }
public async Task CreateOrUpdateAuthorAsync(BlogAuthor author, CancellationToken cancellationToken) { var authorUoW = UnitOfWorkFactory.Create <BlogAuthor, string>(); var dbAuthor = await authorUoW.Entities.Query.GetAsync(author.Id, cancellationToken); if (dbAuthor == null) { await authorUoW.AddAndSaveAsync(author, cancellationToken); } else { await authorUoW.UpdateAndSaveAsync(author, cancellationToken); } }
public async Task <IActionResult> Index(string id) { var cancellationToken = CancellationToken.None; if (string.IsNullOrWhiteSpace(id)) { return(NotFound()); } var post = await BlogRepository.FindBySlugAsync(id, cancellationToken); if (post == null) { return(NotFound()); } if (post.UtcPublishDate == null || post.UtcPublishDate > DateTime.UtcNow.Date) { return(NotFound()); } var author = await BlogRepository.GetAuthorByUserIdAsync(post.CreatedByUserId, cancellationToken); if (author == null) { author = new BlogAuthor() { DisplayName = "Unknown" } } ; var model = new PostViewModel() { Post = BlogPostViewModel.From(post), PostDate = post.UtcPublishDate.Value.ToString("MMMM dd, yyyy"), Author = author }; return(View(new[] { model })); }
public static BlogPost Create( int index = 0, string blogKey = BlogMetaTestData.BlogKey, bool isUpdate = false, string hashPrefix = null, int updatedAtAddedDays = 0, DateTime? updatedAt = null, int tagCount = DefaultTagCount) { var author = new BlogAuthor { ImageUrl = TestUtility.GetTestString( nameof(BlogPost.BlogAuthor) + nameof(BlogAuthor.ImageUrl), blogKey, index, isUpdate), Name = TestUtility.GetTestString( nameof(BlogPost.BlogAuthor) + nameof(BlogAuthor.Name), blogKey, index, isUpdate), SourceId = TestUtility.GetTestString( nameof(BlogPost.BlogAuthor) + nameof(BlogAuthor.SourceId), blogKey, index, isUpdate), Url = TestUtility.GetTestString( nameof(BlogPost.BlogAuthor) + nameof(BlogAuthor.Url), blogKey, index, isUpdate) }; var updatedAtValue = updatedAt ?? TestUpdatedAt.AddDays(updatedAtAddedDays + index); var blogPost = new BlogPost { BlogAuthor = author, BlogKey = blogKey, Content = TestUtility.GetTestString(nameof(BlogPost.Content), blogKey, index, isUpdate) + $"{Environment.NewLine}More content", Hash = TestUtility.GetTestString(nameof(BlogPost.Hash), $"{hashPrefix}{blogKey}", index), ImageUrl = TestUtility.GetTestString(nameof(BlogPost.ImageUrl), blogKey, index, isUpdate), PublishedAt = TestPublishedAt.AddDays(index), SourceId = CreatePostSourceId(index, blogKey), SourceUrl = TestUtility.GetTestString(nameof(BlogPost.SourceUrl), blogKey, index, isUpdate), Summary = TestUtility.GetTestString(nameof(BlogPost.Summary), blogKey, index, isUpdate), BlogPostTags = CreatePostTags(index, tagCount).Select(x => new BlogPostTag(x)).ToList(), Title = TestUtility.GetTestString(nameof(BlogPost.Title), blogKey, index, isUpdate), UpdatedAt = updatedAtValue }; blogPost.UrlSlug = BlogSyncConfigurationDefaults.SlugProvider.GetUrlSlug(blogPost); blogPost.BlavenId = BlogSyncConfigurationDefaults.BlavenIdProvider.GetBlavenId(blogPost); return blogPost; }
/// <summary> /// Add or update author in search index /// </summary> /// <param name="bke"></param> public static void Index(BlogAuthor au) { var index = GetClient().Index(au); }
public static void SeedBlogs(Repository.CurrencyExposureContext context) { //Add Blog Authors var mtAuthor = new BlogAuthor { AuthorName = "Matt Jones", Email = "*****@*****.**" }; var mdAuthor = new BlogAuthor { AuthorName = "Matt Smith", Email = "*****@*****.**" }; context.BlogAuthors.AddOrUpdate( p => p.AuthorName, mtAuthor, mdAuthor); //Add Categories var myHedgingCategory = new BlogCategory { CategoryName = "Hedging Policies", }; var myProductCategory = new BlogCategory { CategoryName = "Products", }; var myGeneralCategory = new BlogCategory { CategoryName = "General", }; var myMarketsCategory = new BlogCategory { CategoryName = "General", }; context.BlogCategorys.AddOrUpdate( p => p.CategoryName, myHedgingCategory, myProductCategory, new BlogCategory { CategoryName = "Foreign Exchange Providers", }, new BlogCategory { CategoryName = "Payments", } ); //Add Blog var blog1 = new Blog { Title = "Confessions of an FX Salesman", Article = Repository.Properties.Resources.BlogArticle1, BlogSummary = BlogArticle1Summary, BlogAuthor = mtAuthor, BlogCategory = myGeneralCategory, Tag = "Hedging, Risk, Exposure", CreateDate = new DateTime(2012, 09, 12, 15, 43, 31) }; var blog2 = new Blog { Title = "Commonly used Hedging Policies - Part 1", Article = Repository.Properties.Resources.BlogArticle2, BlogSummary = BlogArticle2Summary, BlogAuthor = mtAuthor, BlogCategory = myHedgingCategory, Tag = "Payments, Risk, Exposure", CreateDate = new DateTime(2012, 09, 14, 10, 45, 12) }; var blog3 = new Blog { Title = "Understanding Forward Exchange Contracts", Article = Repository.Properties.Resources.BlogArticle3, BlogSummary = BlogArticle3Summary, BlogAuthor = mtAuthor, BlogCategory = myProductCategory, Tag = "Payments, Risk, Exposure", CreateDate = new DateTime(2012, 09, 15, 10, 33, 21) }; var blog4 = new Blog { Title = "FX margins and the Interbank Rate explained", Article = Repository.Properties.Resources.BlogArticle4, BlogSummary = BlogArticle4Summary, BlogAuthor = mtAuthor, BlogCategory = myMarketsCategory, Tag = "Payments, Risk, Exposure", CreateDate = new DateTime(2012, 09, 20, 10, 54, 43) }; var blog5 = new Blog { Title = "Currency Options – How are they really priced?", Article = Repository.Properties.Resources.BlogArticle5, BlogSummary = BlogArticle5Summary, BlogAuthor = mtAuthor, BlogCategory = myProductCategory, Tag = "Payments, Risk, Exposure", CreateDate = new DateTime(2012, 09, 24, 9, 01, 22) }; context.Blogs.AddOrUpdate(p => p.Title, blog1, blog2, blog3); context.Blogs.AddOrUpdate(p => p.Title, blog4, blog5); //Add Blog Comments var blogComment1 = new BlogComment { Blog = blog1, Title = "This is a test Comment 1", Comment = "This is a test Comment 1", Name = "MattDone", Email = "*****@*****.**" }; var blogComment2 = new BlogComment { Blog = blog2, Title = "This is a test Comment 2", Comment = "This is the content of the test comment", Name = "MattDone", Email = "*****@*****.**" }; context.BlogComments.AddOrUpdate(p => new { p.Comment, p.Name }, blogComment1); context.BlogComments.AddOrUpdate(p => new { p.Comment, p.Name }, blogComment2); context.BlogComments.AddOrUpdate(p => new { p.Comment, p.Name }, new BlogComment { Blog = blog2, Title = "This is a test Comment", Comment = "This is a child reply to test Comment 2", Name = "MattTyrrell", Email = "*****@*****.**", ParentComment = blogComment2 }); }
// // GET: /Author/Delete/5 public ActionResult Delete(int id) { BlogAuthor blogauthor = db.BlogAuthors.Single(b => b.AuthorID == id); return(View(blogauthor)); }
// // GET: /Author/Details/5 public ViewResult Details(int id) { BlogAuthor blogauthor = db.BlogAuthors.Single(b => b.AuthorID == id); return(View(blogauthor)); }