public News UpdateNews(UpdateNewsInput input) { //We can use Logger, it's defined in ApplicationService base class. Logger.Info("Updating a news for input: " + input); //Retrieving a task entity with given id using standard Get method of repositories. var news = _newsRepository.Get(input.Id); //Updating changed properties of the retrieved task entity. news.Title = input.Title; news.Intro = input.Intro; news.Content = input.Content; return _newsRepository.Update(news); //We even do not call Update method of the repository. //Because an application service method is a 'unit of work' scope as default. //ABP automatically saves all changes when a 'unit of work' scope ends (without any exception). }
public ActionResult Edit(UpdateNewsInput input) { News.News model = _newsAppService.Get(input.Id); if (ModelState.IsValid) { // OperationResult result = new OperationResult(OperationResultType.Warning, "网络错误,请稍后重试!"); model = _newsAppService.UpdateNews(input); if (model != null) { //result = new OperationResult(OperationResultType.Success, "保存成功"); //return Json(result, JsonRequestBehavior.AllowGet); return new RedirectResult("/News/List"); } } return View(model); }