public ResultDto NewPost(PostDto postDto) { return(Result(() => { var currentUserName = User.Identity.GetUserName(); var command = new NewPostCommand { SiteId = postDto.SiteId, ZoneId = postDto.ZoneId, SerieId = postDto.SerieId, Name = postDto.Name, Title = postDto.Title, MetaTitle = postDto.MetaTitle, MetaDescription = postDto.MetaDescription, PageTemplate = postDto.PageTemplate, IsPrivate = postDto.IsPrivate, IsDiscussionEnabled = postDto.IsDiscussionEnabled, DisableDiscussionDays = postDto.DisableDiscussionDays, IsAnonymousCommentAllowed = postDto.IsAnonymousCommentAllowed, IsRatingEnabled = postDto.IsRatingEnabled, UserName = currentUserName, TagsCommaSeparated = postDto.TagsCommaSeparated, ContentSummary = postDto.ConentSummary, Content = postDto.Content, Links = (postDto.Links ?? new List <LinkDto>()).Select(l => new KeyValuePair <string, string>(l.Type, l.Ref)).ToList(), }; CommandDispatcher.Send(command); })); }
private dynamic CreateNewPost(NewPostCommand command) { var commandResult = _commandInvokerFactory.Handle<NewPostCommand, CommandResult>(command); if (commandResult.Success) { return this.Context.GetRedirect("/mz-admin/posts"); } AddMessage("保存文章时发生错误", "warning"); return View["New", command]; }
private dynamic CreateNewPost(NewPostCommand command) { var commandResult = _commandInvokerFactory.Handle <NewPostCommand, CommandResult>(command); if (commandResult.Success) { return(this.Context.GetRedirect("/mz-admin/posts")); } AddMessage("保存文章时发生错误", "warning"); return(View["New", command]); }
private dynamic CreateNewPost(NewPostCommand command) { var commandResult = _commandInvokerFactory.Handle <NewPostCommand, CommandResult>(command); if (commandResult.Success) { AddMessage("Post was successfully added", "info"); return(this.Context.GetRedirect("/admin/posts")); } AddMessage("Something went wrong while saving new post", "warn"); return(View["New", command]); }
public IActionResult NewPost(NewPostCommand command) { // 获取当前应用静态文件所在物理路径 command.WebRootPath = this._hostingEnvironment.WebRootPath; // 执行新建博文命令 var commandResult = this._commandInvokerFactory.Handle <NewPostCommand, CommandResult>(command); if (!commandResult.IsSuccess) { return(Json(new { code = -1, msg = $"Error:{commandResult.GetErrors()[0]}", url = string.Empty })); } this.ClearCache(); return(Json(new { code = 1, msg = $"Success:提交成功", url = $"/AdminPost/Index/{command.ReturnPageNum}" })); }
public IActionResult NewPost(NewPostCommand command) { // 获取当前应用静态文件所在物理路径 command.WebRootPath = this._hostingEnvironment.WebRootPath; // 设置博文保存的相对路径 command.PostRelativeSavePath = this._webAppConfiguration.Value.settings.PostRelativeSavePath; // 执行新建博文命令 var commandResult = this._commandInvokerFactory.Handle <NewPostCommand, CommandResult>(command); if (!commandResult.IsSuccess) { return(Json(new { code = -1, msg = $"Error:{commandResult.GetErrors()[0]}", url = string.Empty })); } // 更新标签统计 var commandResultB = this._commandInvokerFactory.Handle <UpdateTagCommand, CommandResult>(new UpdateTagCommand()); var tagUpdateMsg = commandResultB.IsSuccess ? "标签更新成功" : "标签统计失败,请手动更新"; this.ClearCache(); return(Json(new { code = 1, msg = $"Success:提交成功,{tagUpdateMsg}", url = $"/AdminPost/Index/{command.ReturnPageNum}" })); }