public void SavePost(PostDetailDTO post) { var postEntity = PostFactory.Create(post.Id, 1, post.Title, post.Subtitle, post.Slug, post.Content); if (postEntity.Id == 0) { PostRepository.Add(postEntity); } else { PostRepository.Update(postEntity); } }
public void InitializePosts() { var authorId = _context.Authors.Select(a => a.Id).First(); var randomNumberGenerator = new Random(); var blogPostSeed = randomNumberGenerator.Next(25, 50); for (int i = 0; i < blogPostSeed; i++) { var title = String.Format("Blog Post {0}", i); var subTitle = String.Format("Sub Title For Blog Post {0}", i); var slug = String.Format("blog-post-{0}", i); var post = PostFactory.Create(0, authorId, title, subTitle, slug, ""); post.InsertDate = DateTime.UtcNow; _context.Posts.Add(post); } _context.SaveChanges(); }
private void btnGo_Click(object sender, EventArgs e) { if (!_blogSelected) { MessageBox.Show("First connect to blog from File>Connect!"); return; } if (lvItems.SelectedItems.Count == 0) { MessageBox.Show("Select items to transfer!"); return; } var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); _stopWatch = new Stopwatch(); _stopWatch.Start(); EnDisItems(false); lblDateTime.Text = "Started at " + DateTime.Now.ToLongTimeString(); using (var dal = new Dal(MySqlConnectionString)) { _blogCache = new BlogCache(dal); if (_options.UseCache) { SetStatus("Loading present posts and tags in the blog(this may take some time)..."); Application.DoEvents(); _blogCache.Start(_options.BlogUrl); Application.DoEvents(); } SetStatus("Ready"); ResetBarStatus(true); barStatus.Maximum = lvItems.SelectedItems.Count; _postFactory = new PostFactory( SiteConfig, new Ftp(FtpConfiguration), _blogCache, dal, _options); var items = ItemsFromListView(lvItems.SelectedItems); _postFactory.PostCreated += PostCreated; _postFactory.PostBeingCreated += PostBeingCreated; _postFactory.PostsCreated += PostsCreated; _postFactory.PostCreationStopped += PostCreationStopped; _postFactory.Create(items); } }
public async Task <PostResponseModel> Create(PostRequestModel model) { return(await _factory.Create(model)); }