Esempio n. 1
0
        public void Handle(DeleteArticleTagCommand command)
        {
            var articleTag = _articleTagRepository.Load(command.ArticleTagId);

            Guard.IsNotNull(articleTag, "articleType");
            _articleTagRepository.Delete(articleTag);
        }
        public ActionResult Delete(long id)
        {
            try
            {
                if (_repository.Delete(id) != EntityStates.Deleted)
                {
                    throw new Exception(_errorGenerator.GetExceptionResponse <DataModels.ArticleTag>(ActionType.Delete));
                }

                var messageResponse = _errorGenerator.GetMessageResponse <DataModels.ArticleTag>(ActionType.Delete, id, success: true);
                Log.Warning(messageResponse.LogTemplate, messageResponse.Message);
                return(new JsonResult(new { messageResponse.Message }));
            }
            catch (Exception ex)
            {
                var input           = new { Id = id };
                var messageResponse = _errorGenerator.GetMessageResponse <DataModels.ArticleTag, object>(ActionType.Delete, input, exception: ex);
                Log.Error(messageResponse.LogTemplate, messageResponse.Message, input);
                throw new Exception(messageResponse.Message);
            }
        }