public async Task <IActionResult> ArticleDetail(int id, Article model) { var now = DateTime.Now; var result = new Result(); if (model.Name.IsNullOrEmpty()) { result.Error("请输入名称"); return(Json(result)); } if (id > 0) { var old = DefaultStorage.ArticleGet(id); if (old == null) { result.Message = "数据不存在"; return(Json(result)); } var status = await TryUpdateModelAsync(old); if (status) { result.Status = DefaultStorage.ArticleUpdate(old); if (!result.Status) { result.Message = "更新失败"; } } else { result.Message = "参数有误"; } return(Json(result)); } model.Extra = string.Empty; model.UserId = User.Id; model.CreatedBy = User.Name; model.CreatedOn = now; model.ModifiedBy = User.Name; model.ModifiedOn = now; var newId = DefaultStorage.ArticleCreate(model); if (result.Status = newId > 0) { result.Success(); } return(Json(result)); }
public IActionResult ArticleDetail(int id) { var now = DateTime.Now; var model = new ArticleDetailModel(); model.Article = new Article(); model.Article.StartedOn = now; model.Article.StoppedOn = now.AddDays(5); if (id > 0) { model.Article = DefaultStorage.ArticleGet(id); } return(View(model)); }