public void ShouldRegisterArticle() { PopulateRepository(); RegisterArticleCommand command = new RegisterArticleCommand { Body = "Olá, mundo! Esse é um artigo com mais de 50 caracteres para passar no teste.", Slug = "artigo-do-ola-mundo", Title = "Título do artigo aqui", CategoryId = new Guid("9008f2ce-3700-42ca-a514-48d0fa37c2f6") }; applicationService.Register(command); Assert.AreEqual(3, applicationService.GetAllArticles().Count()); }
public void Register(RegisterArticleCommand command) { command.Validate(); if (AddNotifications(command)) { return; } ArticleCategory category = _categoryRepository.GetById(command.CategoryId); LedgerIdentityUser user = _identityResolver.GetUser(); if (NotifyNullCategory(category)) { return; } Article article = new Article(command.Slug, command.Title, command.Body, command.CategoryId, user.Id); _articleRepository.Register(article); Commit(); }
//[Authorize(Policy = "AdminAccount")] public IActionResult Register([FromBody] RegisterArticleCommand command) { _articleAppService.Register(command); return(CreateResponse()); }