public override Task <ModuleViewComponentResult> OnViewComponentLoad() { AdminArticleModel model = new AdminArticleModel(this); ArticleInfo article = null; // Update if (Request.Method == "POST") { String userId = _userManager.GetUserId(HttpContext.User); article = _articleBusiness.GetArticle(ArticleId); if (article == null) { article = new ArticleInfo(); article.CreatedAt = DateTime.UtcNow; article.CreatedBy = userId; } article.ArticleId = model.ArticleId; article.ArticleContent = model.ArticleContent; article.ArticleOrder = model.ArticleOrder; article.CreatedAt = DateTime.Now; article.ImageUrl = model.ImageUrl; article.Title = model.Title; article.UserId = userId; article.UpdatedAt = DateTime.UtcNow; article.UpdatedBy = userId; article.ModuleId = Module.ModuleId; _articleBusiness.SaveArticle(article); } if (article == null) { article = _articleBusiness.GetArticle(ArticleId); } if (article == null) { return(Task.FromResult(ModuleView("ArticleEdit", model))); } model.ArticleId = ArticleId; model.ArticleContent = article.ArticleContent; model.ArticleOrder = article.ArticleOrder; model.ImageUrl = article.ImageUrl; model.Title = article.Title; return(Task.FromResult(ModuleView("ArticleEdit", model))); }
public IActionResult Get(int id) { ArticleInfo article = _articleBusiness.GetArticle(id); if (article == null) { return(NotFound()); } ArticleModel model = new ArticleModel(); model.ArticleContent = article.ArticleContent; model.ArticleId = article.ArticleId; model.ArticleOrder = article.ArticleOrder; model.ImageUrl = article.ImageUrl; model.ModuleId = article.ModuleId; model.Title = article.Title; model.DateUpdated = article.UpdatedAt.ToString("dd/MM/yyyy"); return(Json(model)); }