public ActionResult DeleteConfirmed(int id)
        {
            var deleteArticleInput = new DeleteArticleInput {
                Id = id
            };

            _articleAppService.DeleteArticle(deleteArticleInput);

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public void DeleteArticle(DeleteArticleInput input)
 {
     _articleRepository.Delete(input.Id);
 }