public ActionResult DeleteConfirmed(int id) { var deleteArticleInput = new DeleteArticleInput { Id = id }; _articleAppService.DeleteArticle(deleteArticleInput); return(RedirectToAction("Index")); }
public async Task <DeleteArticlePayload> DeleteArticleAsync( DeleteArticleInput input, [ScopedService] NmediaContext dbContext, CancellationToken cancellationToken ) { Article entity = await dbContext.Articles .SingleOrDefaultAsync(x => x.Uuid == input.Id, cancellationToken) ?? throw new ArgumentException($"The Article (ID={input.Id}) could not be found.", nameof(input)); dbContext.Articles.Remove(entity); await dbContext.SaveChangesAsync(cancellationToken); return(new DeleteArticlePayload(entity)); }
public ResponseInfoModel Delete([FromBody] DeleteArticleInput input) { ResponseInfoModel json = new ResponseInfoModel() { Success = 1, Result = new object() }; try { CheckModelState(); int[] idInts = ConvertStringToIntArr(input.ids); if (!_articleService.Delete(idInts)) { json.Success = 0; json.Result = LocalizationConst.DeleteFail; } else { foreach (var id in idInts) { _logService.Insert(new Log() { ActionContent = LocalizationConst.Delete, SourceType = _moduleName, SourceID = id, LogUserID = input.userID, LogTime = DateTime.Now, LogIPAddress = IPHelper.GetIPAddress, }); } } } catch (Exception e) { DisposeUserFriendlyException(e, ref json, "api/article/delete", LocalizationConst.DeleteFail); } return(json); }
public void DeleteArticle(DeleteArticleInput input) { _articleRepository.Delete(input.Id); }