public async Task Add(WordModel input) { await WordRepository.InsertAsync(new Word { Content = input.Content, Title = input.Title }); }
public async Task<bool> AddOrUpdate(WordModel input) { var model =GuidHelp.Chack(input.Id)? await WordRepository.FirstOrDefaultAsync(input.Id): await WordRepository.FirstOrDefaultAsync(s => s.Title == input.Title); if (model != null) { model.Content = input.Content; return true; } else { await Add(input); } return false; }
public async Task<ActionResult> AddWord(WordModel input) { if (ModelState.IsValid) { var isUpdate = await ManagementService.AddOrUpdate(input); Thread.Sleep(2000); if (isUpdate) { throw new UpdateInfo("更新文章成功!"); } else { throw new SuccessInfo("发布文章成功!"); } } return View(); }