public async Task Put(NewsArticleViewModel model)
 {
     try
     {
         await NewsArticleService.Update(model.ToEntity());
     }
     catch {
         Response.StatusCode = StatusCodes.Status400BadRequest;
     }
 }
Exemplo n.º 2
0
        public IActionResult Edit(NewsArticleEditViewModel viewModel)
        {
            NewsArticle newsArticle = newsArticleService.GetByID(viewModel.NewsArticle.ID);

            newsArticle.Title        = viewModel.NewsArticle.Title;
            newsArticle.Body         = viewModel.NewsArticle.Body;
            newsArticle.DateModified = DateTime.Now;
            newsArticle.CategoryID   = viewModel.CategoryID ?? null;

            newsArticleService.Update(newsArticle);
            return(RedirectToAction("Details", newsArticle));
        }
Exemplo n.º 3
0
        public async Task ShouldUpdateNewsArticle()
        {
            await addTwitterUser();
            await addNewsArticle();

            var entityToUpdate = (await newsArticleService.GetByFilter(x => x.Source == "articleFromMemory")).FirstOrDefault();

            entityToUpdate.CredibilityScore = 10;
            await newsArticleService.Update(entityToUpdate);

            var result = (await newsArticleService.GetByFilter(x => x.Source == "articleFromMemory")).FirstOrDefault();


            Assert.Equal(10, result.CredibilityScore ?? 0);
        }