public void AddFakePosts(int count) { List <Post> posts = new List <Post>(); Random rand = new Random(); for (int i = 0; i < count; i++) { int postStatusRand = rand.Next(0, 2); PostStatus status = PostStatus.Pending; switch (postStatusRand) { case 0: status = PostStatus.Sent; break; case 1: status = PostStatus.Pending; break; } int isCommentsOnRand = rand.Next(0, 2); bool isComments; if (isCommentsOnRand == 0) { isComments = false; } else { isComments = true; } var myData = new Faker <Post>() .RuleFor(u => u.Title, u => u.Name.FullName()) .RuleFor(u => u.Body, u => u.Lorem.Paragraphs()) .RuleFor(u => u.CategoryId, u => rand.Next(1, _context.Categories.Count())) .RuleFor(u => u.DateTime, u => u.Date.Past()) .RuleFor(u => u.LastEditDate, u => u.Date.Future()) .RuleFor(u => u.Status, u => status) .RuleFor(u => u.IsCommentsOn, u => isComments) .RuleFor(u => u.MediaId, u => rand.Next(1, _context.Medias.Count())) .RuleFor(u => u.User, u => _userManager.GetUsersInRoleAsync(SD.AdminEndUser).Result[0]); myData.Generate(); posts.Add(myData); } _context.Posts.AddRange(posts); _context.SaveChanges(); AddFakePostsExtras(count); }
private async void DownloadBtn_Click(object sender, RoutedEventArgs e) { string subRedditName = this.SubredditTBox.Text; PostStatus postStatus = (PostStatus)this.PostStatusComboBox.SelectedItem; int maxPosts = Int32.Parse(PostCountTBox.Text); RedditRipper ripper = new RedditRipper(subRedditName, postStatus, maxPosts); SubReddit subReddit = await ripper.GetSubReddit(); foreach (Post post in subReddit.Data.Posts) { DownloadItem item = new DownloadItem(); item.Title = post.Data.Title; item.Url = post.Data.Url; if (item.Url.Contains("gfycat.com")) { item.Url = RedditAPI.utils.Utils.GetImageUrlFromGfycat(item.Url); } item.FileName = Web.utils.Utils.Instance.GetFileNameFromUrl(item.Url); item.FileName = string.IsNullOrEmpty(item.FileName) || string.IsNullOrWhiteSpace(item.FileName) ? $"{item.Title}.png" : item.FileName; this.DownloadLogBox.Items.Add(item); Downloader downloader = new Downloader($"Downloads\\{subRedditName}\\{postStatus.ToString()}"); downloader.DownloadAsync(item); } }
public static string ToRPC(this PostStatus e) { switch (e) { case PostStatus.Any: return("any"); case PostStatus.AutoDraft: return("pending"); case PostStatus.Draft: return("draft"); case PostStatus.Future: return("future"); case PostStatus.Inherit: return("inherit"); case PostStatus.Pending: return("pending"); case PostStatus.Private: return("private"); case PostStatus.Published: return("publish"); case PostStatus.Trash: return("trash"); } throw new NotImplementedException(); }
public PostPagingSpec(PostStatus postStatus, string keyword, int pageSize, int offset) : base(p => null == keyword || p.Title.Contains(keyword)) { switch (postStatus) { case PostStatus.Draft: AddCriteria(p => !p.IsPublished && !p.IsDeleted); break; case PostStatus.Published: AddCriteria(p => p.IsPublished && !p.IsDeleted); break; case PostStatus.Deleted: AddCriteria(p => p.IsDeleted); break; case PostStatus.Default: AddCriteria(p => true); break; default: throw new ArgumentOutOfRangeException(nameof(postStatus), postStatus, null); } ApplyPaging(offset, pageSize); ApplyOrderByDescending(p => p.PubDateUtc); }
public void ChangeStatus(int id, PostStatus status) { var post = PostsRepository.GetById(id); post.Status = status; PostsRepository.Save(post); }
/// <summary> /// <inheritdoc /> /// </summary> /// <returns></returns> public PostBuilder InitializeWithDefaultValues() { CommandStatus = CommentStatusValue.Open; PingStatus = PingStatusValue.Open; Format = PostFormat.Standard; Status = PostStatus.Pending; return(this); }
/// <summary> /// 获取话题内指定状态的贴子总数 /// </summary> public async Task <long> GetCountByTopicAsync(Topic topic, PostStatus status) { if (topic == null) { throw new ArgumentNullException(nameof(topic)); } string sql = "SELECT count(*) FROM post Where topic_id = @topicId AND post_status = @postStatus;"; return(await this.DbConnection.ScalarAsync <long>(sql, new { topicId = topic.Id, postStatus = status })); }
public IEnumerable<Post> GetAllPosts(PostStatus status) { switch (status) { case PostStatus.Unpublished: return _postRepository.GetUnpublished(); default: return _postRepository.GetPublished(); } }
/// <summary> /// 获取该标签指定状态的帖子总数 /// </summary> public async Task <long> GetPostCountAsync(Tag tag, PostStatus status = PostStatus.Publish) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } string sql = "select count(post.*) from post inner join post_tag on post.id = post_tag.post_id inner join tag on post_tag.tag_id = tag.id where tag.id = @tagId and post_status = @postStatus;"; return(await this.DbConnection.ScalarAsync <long>(sql, new { tagId = tag.Id, postStatus = status })); }
public PostStatus GetById(string name) { using (SqlConnection cn = new SqlConnection(Settings.ConnectionString)) { var p = new DynamicParameters(); p.Add("status", name); PostStatus stat = cn.Query <PostStatus>("GetPostStatusByName", p, commandType: CommandType.StoredProcedure).FirstOrDefault(); return(stat); } }
public Post(string Id, string Author, string Content, string SectionTitle, string TopicTitle, DateTime Date, PostStatus Status) { this.Id = Id; this.Author = Author; this.Content = Content; this.SectionTitle = SectionTitle; this.TopicTitle = TopicTitle; this.Date = Date; this.Status = Status; }
public void Valid_Value_Returns_PostStatusType(string input, PostStatus expected) { // Arrange var handler = new PostStatusTypeHandler(); // Act var result = handler.Parse(input); // Assert Assert.Same(expected, result); }
public BaseRestApiInterface AppliedStatus(int blogId, PostStatus pt) { User user = jwtAuth.GetUserFromAccessToken(jwtAuth.ValidateToken(Request.Headers.Authorization.Scheme), false); if (user == null) { throw new BlogException("userNotAccessRight", new String[] { user.UserId }); } BaseRestApiResult result = new BaseRestApiResult(); result.process((ctx) => { var blogPost = ctx.BlogPosts.Find(new int[] { blogId }); if (blogPost == null) { throw new BlogException("blogpostnotExists", new string[] { blogPost.Title }); } else { switch (pt) { case PostStatus.Draft: blogPost.Status = (int)PostStatus.Draft; break; case PostStatus.ReadToPublish: blogPost.Status = (int)PostStatus.ReadToPublish; break; case PostStatus.Reject: blogPost.Status = (int)PostStatus.Reject; break; case PostStatus.Published: blogPost.Status = (int)PostStatus.Published; break; case PostStatus.Archived: blogPost.Status = (int)PostStatus.Archived; break; default: break; } blogPost.ModifiedDate = DateTime.Now; blogPost.ModifiedBy = user.UserName; ctx.SaveChanges(); } }); return(result); }
public void Sets_Value_To_CommentType_Name(string expected, PostStatus input) { // Arrange var handler = new PostStatusTypeHandler(); var parameter = Substitute.For <IDbDataParameter>(); // Act handler.SetValue(parameter, input); // Assert parameter.Received().Value = expected; }
public void Adds_Status_To_Where() { // Arrange var(builder, v) = Setup(); var status = new PostStatus(Rnd.Str); // Act var result = builder.AddWhereStatus(v.Parts, status); // Assert AssertWhere(v.Parts, result, Post.Status, Compare.Equal, status); }
public async Task <int> UpdatePostStatus(int postId, PostStatus status) { var post = await zemBlogDbContext.Posts.FindAsync(postId); post.PostStatus = status; if (status == PostStatus.Approved) { post.PublishedDate = DateTime.Now; } return(await zemBlogDbContext.SaveChangesAsync()); }
private void SetPostStatus() { string financialYear = _parameterManager.GetCurrentFinancialYear(); if (string.IsNullOrWhiteSpace(financialYear)) { _postStatus = PostStatus.FinancialYearNotOpened; } else { _postStatus = PostStatus.Postable; } }
public async Task ChangePostStatus(int id, PostStatus newStatus) { var entity = new Post { Id = id, Status = newStatus }; _context.Attach(entity); _context.Entry(entity).Property(x => x.Status).IsModified = true; await _context.SaveChangesAsync(); }
public bool ChangeStatus(string id, PostStatus status) { try { var model = _postRepository.FindById(id); model.Status = status; _postRepository.Update(model); return(true); } catch (Exception error) { throw error; } }
public Post(string title, string description, PostStatus status, DateTime createTime, DateTime publishData, string photoUrl, List <Tag> tags, PostDetails postDetails, User author, int id = 0) { this.Id = id; this.Title = title; this.Description = description; this.Tags = tags; this.Status = status; this.CreateDate = createTime; this.PublishDate = publishData; this.PhotoUrl = photoUrl; this.Details = postDetails; this.Author = author; }
public IHttpActionResult ChangeStatus([FromUri] string id, [FromUri] PostStatus status) { try { var responseData = _postService.ChangeStatus(id, status); _postService.Save(); return(Ok(responseData)); } catch (Exception ex) { _logger.LogError("Error at method: ChangeStatus - PostApi," + ex.InnerException.InnerException.Message + ""); return(BadRequest("Error System")); } }
protected override Post DoFindByKey(int id) { string querySqlStatement = this.GetAggregateRootQuerySqlStatementById(); Func <IEnumerable <Post>, IEnumerable <PostStatus>, IEnumerable <Post> > map = (postList, statusList) => { Post post = postList.SingleOrDefault(); PostStatus postStatus = statusList.SingleOrDefault(); post.Status = postStatus; return(new Post[] { post }); }; return(this.DapperRepositoryContext.QueryMultiple <Post, PostStatus, Post>(querySqlStatement, map, new { Id = id }).SingleOrDefault()); }
public static void UpdatePostStatus(int id, PostStatus status) { //UpdateVersionCount(id); QueryCommand command = new QueryCommand("Update graffiti_Posts Set Status = " + DataService.Provider.SqlVariable("Status") + " Where Id = " + DataService.Provider.SqlVariable("Id")); List <Parameter> parameters = Post.GenerateParameters(); command.Parameters.Add(Post.FindParameter(parameters, "Status")).Value = (int)status; command.Parameters.Add(Post.FindParameter(parameters, "Id")).Value = id; DataService.ExecuteNonQuery(command); ZCache.RemoveByPattern("Posts-"); ZCache.RemoveCache("Post-" + id); }
/// <summary> /// generates the url for all requests to fetch posts from WordPress /// </summary> /// <param name="site">the site name. insert without http:// prefix</param> /// <param name="type">the post type based on the PostType enumeration</param> /// <param name="status">the post status based on the PostStatus enumeration</param> /// <param name="number">the number of posts to fetch (0-100). default value goes to 10.</param> /// <returns>the generated post url as string</returns> public string postsUrl(string site, PostType type, PostStatus status, int?number = null) { int postNumber = 10; if (number != null) { postNumber = Convert.ToInt32(number); } var postType = Enum.GetName(typeof(PostType), type).ToLower(); var postStatus = Enum.GetName(typeof(PostStatus), status).ToLower(); return(string.Format("https://public-api.wordpress.com/rest/v1/sites/{0}/posts/?number={1}&type={2}&status={3}", site, number, postType, postStatus)); }
public Task <IReadOnlyList <PostSegment> > ListSegment(PostStatus postStatus) { var spec = new PostSpec(postStatus); return(_postRepo.SelectAsync(spec, p => new PostSegment { Id = p.Id, Title = p.Title, Slug = p.Slug, PubDateUtc = p.PubDateUtc, IsPublished = p.IsPublished, IsDeleted = p.IsDeleted, CreateTimeUtc = p.CreateTimeUtc, Hits = p.PostExtension.Hits })); }
public void ChangePostStatus(Post post, PostStatus newStatus) { PostStatus prevStatus = post.Status; try { post.Status = newStatus; _context.Posts.Update(post); _context.SaveChanges(); } catch (Exception ex) { post.Status = prevStatus; throw ex; } }
public string ApprovePostbyId(ApiUpdatePostModel postUpdate) { string result = string.Empty; PostStatus newStatus = (PostStatus)postUpdate.PostStatus; Post post = _postRepository.GetPostbyId(postUpdate.PostId); if (post != null) { _postRepository.ChangePostStatus(post, newStatus); result = Constants.ResultOk; } else { result = Constants.InvalidPostMessage; } return(result); }
public static List <SelectListItem> ToSelectListItems(this PostStatus status) => new List <SelectListItem> { new SelectListItem( AppTextDisplay.PostStatusDraft, ((int)PostStatus.Draft).ToString(), status == PostStatus.Draft), new SelectListItem( AppTextDisplay.PostStatusPlanned, ((int)PostStatus.Planned).ToString(), status == PostStatus.Planned), new SelectListItem( AppTextDisplay.PostStatusPublished, ((int)PostStatus.Published).ToString(), status == PostStatus.Published) };
/// <summary> /// generates the url for all requests to fetch posts or pages from WordPress /// </summary> /// <param name="site">the site url. insert without http:// prefix</param> /// <param name="type">the post type based on the PostType enumeration</param> /// <param name="status">the post status based on the PostStatus enumeration</param> /// <param name="number">the number of posts to fetch (0-100). default value goes to 10.</param> /// <param name="offset">the 0-indexed offset for the request. Default value goes to 0. Use this parameter for pagination.</param> /// <returns>the generated post url as string</returns> private static string postUrl(string site, PostType type, PostStatus status, int?number = null, int?offset = null) { if (!number.HasValue) { number = 10; } if (!offset.HasValue) { offset = 0; } var postType = Enum.GetName(typeof(PostType), type).ToLowerInvariant(); var postStatus = Enum.GetName(typeof(PostStatus), status).ToLowerInvariant(); return(string.Format("https://public-api.wordpress.com/rest/v1/sites/{0}/posts/?number={1}&offset={2}&type={3}&status={4}", site, number, offset, postType, postStatus)); }
public PostStatus GetPostStatusById(long id) { const PostStatus status = PostStatus.Visible; //if (selectedPost.Status == "visible") //{ // status = PostStatus.Visible; //} //else if (selectedPost.Status == "hidden") //{ // status = PostStatus.Hidden; //} //else if (selectedPost.Status == "draft") //{ // status = PostStatus.Draft; //} return(status); }
public object Convert(object value, Type targetType, object parameter, string language) { PostStatus ps = (PostStatus)value; switch (ps) { case PostStatus.Skip: return(" 朕无视"); case PostStatus.Read: return(" 朕已阅"); case PostStatus.Favorite: return(" 朕收藏"); default: return(string.Empty); } }
public ApiResponse <LoginRadiusPostResponse> PostStatus(string accessToken, PostStatus model) { Validate(new ArrayList { accessToken }); var additionalQueryParams = new QueryParameters { ["access_token"] = accessToken, ["Imageurl"] = model.Imageurl, ["Url"] = model.Url, ["Title"] = model.Title, ["Status"] = model.Status, ["Caption"] = model.Caption, ["Description"] = model.Description }; return(ConfigureAndExecute <LoginRadiusPostResponse>(RequestType.Social, HttpMethod.Post, "status", additionalQueryParams)); }
public bool ChangePostStatus(long idPost, PostStatus status) { using (var conn = DbUtilities.Connection) { return conn.Execute(QueryPostStore.SetPostStatus, new { idPost = idPost, idStatus = (int) status, timeStamp = DateTime.Now }) > 0; } }
public static List<CategoryCount> GetCategoryCountForStatus(PostStatus status, string authorID) { List<CategoryCount> catCounts = new List<CategoryCount>(); List<CategoryCount> final = new List<CategoryCount>(); DataProvider dp = DataService.Provider; QueryCommand cmd = new QueryCommand(String.Empty); if (String.IsNullOrEmpty(authorID)) { cmd.Sql = @"select c.Id, " + dp.SqlCountFunction("c.Name") + @" as IdCount, p.CategoryId from graffiti_Posts AS p inner join graffiti_Categories AS c on p.CategoryId = c.Id where p.Status = " + dp.SqlVariable("Status") + @" and p.IsDeleted = 0 group by c.Id, p.CategoryId"; } else { cmd.Sql = @"select c.Id, " + dp.SqlCountFunction("c.Name") + @" as IdCount, p.CategoryId from ((graffiti_Posts AS p inner join graffiti_Categories AS c on p.CategoryId = c.Id) inner join graffiti_Users AS u on p.CreatedBy = u.Name) where p.Status = " + dp.SqlVariable("Status") + @" and p.IsDeleted = 0 and u.Id = " + dp.SqlVariable("AuthorId") + @" group by c.Id, p.CategoryId"; } cmd.Parameters.Add(Post.FindParameter("Status")).Value = (int)status; if (!String.IsNullOrEmpty(authorID)) { cmd.Parameters.Add("AuthorId", Convert.ToInt32(authorID), Graffiti.Core.User.FindParameter("Id").DbType); } using (IDataReader reader = DataService.ExecuteReader(cmd)) { while (reader.Read()) { CategoryCount catCount = new CategoryCount(); catCount.ID = Int32.Parse(reader["Id"].ToString()); catCount.Count = Int32.Parse(reader["IdCount"].ToString()); catCount.CategoryId = Int32.Parse(reader["CategoryId"].ToString()); catCounts.Add(catCount); } reader.Close(); } // populate the category name CategoryCollection cats = new CategoryController().GetAllCachedCategories(); List<CategoryCount> tempParentList = new List<CategoryCount>(); foreach (CategoryCount cc in catCounts) { Category temp = cats.Find( delegate(Category c) { return c.Id == cc.ID; }); if (temp != null) { cc.Name = temp.Name; cc.ParentId = temp.ParentId; } if (cc.Count > 0 && cc.ParentId >= 1) { // if it's not already in the list, add it CategoryCount parent = catCounts.Find( delegate(CategoryCount cac) { return cac.ID == cc.ParentId; }); if (parent == null) { parent = tempParentList.Find( delegate(CategoryCount cac) { return cac.ID == cc.ParentId; }); if (parent == null) { Category tempParent = cats.Find( delegate(Category cttemp) { return cttemp.Id == cc.ParentId; }); parent = new CategoryCount(); parent.ID = tempParent.Id; parent.ParentId = tempParent.ParentId; parent.Name = tempParent.Name; parent.Count = 0; tempParentList.Add(parent); } } } } catCounts.AddRange(tempParentList); List<CategoryCount> filteredPermissions = new List<CategoryCount>(); filteredPermissions.AddRange(catCounts); foreach (CategoryCount ac in catCounts) { if (!RolePermissionManager.GetPermissions(ac.CategoryId, GraffitiUsers.Current).Read) filteredPermissions.Remove(ac); } foreach (CategoryCount ac in filteredPermissions) { CategoryCount existing = final.Find( delegate(CategoryCount catcount) { return catcount.ID == ac.ID; }); if (existing == null) { final.Add(ac); } else { existing.Count += ac.Count; } } return final; }
public static void UpdatePostStatus(int id, PostStatus status) { //UpdateVersionCount(id); QueryCommand command = new QueryCommand("Update graffiti_Posts Set Status = " + DataService.Provider.SqlVariable("Status") + " Where Id = " + DataService.Provider.SqlVariable("Id")); List<Parameter> parameters = Post.GenerateParameters(); command.Parameters.Add(Post.FindParameter(parameters, "Status")).Value = (int)status; command.Parameters.Add(Post.FindParameter(parameters, "Id")).Value = id; DataService.ExecuteNonQuery(command); ZCache.RemoveByPattern("Posts-"); ZCache.RemoveCache("Post-" + id); }
public IEnumerable<PostLight> GetPostByStatus(PostStatus status) { return PostMapper.Map(_postRepository.GetPostByStatus((int) status)); }
public static List<AuthorCount> GetAuthorCountForStatus(PostStatus status, string categoryID) { List<AuthorCount> autCounts = new List<AuthorCount>(); List<AuthorCount> final = new List<AuthorCount>(); QueryCommand cmd = new QueryCommand( @"select u.Id, " + DataService.Provider.SqlCountFunction("u.Id") + @" as IdCount, u.ProperName, p.CategoryId from graffiti_Posts AS p inner join graffiti_Users as u on p.CreatedBy = u.Name where p.Status = " + DataService.Provider.SqlVariable("Status") + @" and p.IsDeleted = 0"); if(!String.IsNullOrEmpty(categoryID)) { cmd.Sql += " and p.CategoryId = " + DataService.Provider.SqlVariable("CategoryId"); } cmd.Sql += " group by u.Id, u.ProperName, p.CategoryId"; List<Parameter> parameters = Post.GenerateParameters(); cmd.Parameters.Add(Post.FindParameter(parameters, "Status")).Value = (int)status; if (!String.IsNullOrEmpty(categoryID)) { cmd.Parameters.Add(Post.FindParameter(parameters, "CategoryId")).Value = Convert.ToInt32(categoryID); } using (IDataReader reader = DataService.ExecuteReader(cmd)) { while (reader.Read()) { AuthorCount autCount = new AuthorCount(); autCount.ID = Int32.Parse(reader["Id"].ToString()); autCount.Count = Int32.Parse(reader["IdCount"].ToString()); autCount.Name = reader["ProperName"].ToString(); autCount.CategoryId = Int32.Parse(reader["CategoryId"].ToString()); autCounts.Add(autCount); } List<AuthorCount> filteredPermissions = new List<AuthorCount>(); filteredPermissions.AddRange(autCounts); foreach (AuthorCount ac in autCounts) { if (!RolePermissionManager.GetPermissions(ac.CategoryId, GraffitiUsers.Current).Read) filteredPermissions.Remove(ac); } foreach (AuthorCount ac in filteredPermissions) { AuthorCount existing = final.Find( delegate(AuthorCount authcount) { return authcount.Name == ac.Name; }); if (existing == null) { final.Add(ac); } else { existing.Count += ac.Count; } } reader.Close(); } return final; }
/// <summary> /// Adds an article. /// </summary> /// <returns></returns> public static Article AddArticle(Nav nav, string subject, string body, string postSlug, string tagString, DateTime dateCreated, PostStatus status) { Article post = new Article(nav); // ---------------------------------------------------------------- UserId post.UserId = AccountManager.GetUserId(SiteContext.Current.UserName); // ---------------------------------------------------------------- Subject // must come before Slug if (string.IsNullOrWhiteSpace(subject)) subject = string.Empty; if (subject.Length > BlogConfig.PostTitle_MaxLength) { subject = subject.Substring(0, BlogConfig.PostTitle_MaxLength); } post.Subject = WebHelper.HtmlEncode(subject); // ---------------------------------------------------------------- Slug // if user did not provide a slug for post, we take it from subject if (string.IsNullOrWhiteSpace(postSlug)) { post.PostSlug = WebHelper.FormatSlug(post.Subject); } else // use provided his own slug for post { post.PostSlug = WebHelper.FormatSlug(postSlug); if (string.IsNullOrWhiteSpace(post.PostSlug)) post.PostSlug = WebHelper.FormatSlug(post.Subject); } // user didn't provide a slug or subject, use ticks and no need to check for dup at data source if (string.IsNullOrWhiteSpace(post.PostSlug)) // should I also incl slug that is less than 2 chars ? { post.PostSlug = TickHelper.GetReverseChronologicalTicks(); post.RequireSlugValidationAtDataSource = false; } else // otherwise need to check for duplicate slug at datasource { post.RequireSlugValidationAtDataSource = true; } // ---------------------------------------------------------------- Body post.Body = body; // TODO: html cleaning, light box on img // ---------------------------------------------------------------- IP post.IP = WebHelper.GetIP(); // ---------------------------------------------------------------- Dates post.DateCreated = dateCreated.ToUniversalTime(); post.DateUpdated = dateCreated.ToUniversalTime(); // ---------------------------------------------------------------- Status // tags depend on publish post.PostStatus = status; // ---------------------------------------------------------------- Tags post.Tags = Tag.GetTagsFromTagsString(nav, tagString); // ---------------------------------------------------------------- Execution post.PostId = BlogApp._AddPost(post); return post; }
private void SetPostReadState(string format, string id, PostStatus status) { var key = string.Format(format, id); settings.Values[key] = (int)status; }
/// <summary> /// Updates an article by postId. /// </summary> /// <remarks> /// /// </remarks> public static Article UpdateArticle(Nav nav, int postId, string subject, string body, string tagString, string postSlug, DateTime dateCreated, PostStatus status) { Article post = (Article)BlogApp.GetPost(nav, postId); // ---------------------------------------------------------------- DateCreated post.DateCreated = dateCreated.ToUniversalTime(); // Let us set it to UTC time here in BLL instead of DAL // ---------------------------------------------------------------- PostStatus // post.PostStatus = status; // ---------------------------------------------------------------- Subject // // must come before Slug if (string.IsNullOrWhiteSpace(subject)) subject = string.Empty; if (subject.Length > (BlogConfig.PostTitle_MaxLength)) { subject = subject.Substring(0, BlogConfig.PostTitle_MaxLength); } post.Subject = WebHelper.HtmlEncode(subject); // ---------------------------------------------------------------- Slug // string slugOld = post.PostSlug; // get the current slug to invalidate cache for this post after update if (string.IsNullOrWhiteSpace(postSlug)) { post.PostSlug = WebHelper.FormatSlug(post.Subject); } else { post.PostSlug = WebHelper.FormatSlug(postSlug); // if the user given slug is illegal if (string.IsNullOrWhiteSpace(post.PostSlug)) post.PostSlug = WebHelper.FormatSlug(post.Subject); } if (string.IsNullOrWhiteSpace(post.PostSlug)) { post.PostSlug = post.PostId.ToString(); post.RequireSlugValidationAtDataSource = false; } else { post.RequireSlugValidationAtDataSource = true; } // if new slug is equal to old one, then no need to validate for duplication in DAL if (slugOld.Equals(post.PostSlug, StringComparison.InvariantCultureIgnoreCase)) post.RequireSlugValidationAtDataSource = false; // ---------------------------------------------------------------- Body // post.Body = body; // ---------------------------------------------------------------- Tags // post.Tags = Tag.GetTagsFromTagsString(nav, tagString); // ---------------------------------------------------------------- Execution BlogApp.UpdatePost(post, slugOld); return post; }