Ejemplo n.º 1
0
        public async Task AddNewsShouldSuccess()
        {
            string userId = "Sam";
            News   news   = new News {
                Title = "chandrayaan2-spacecraft", Content = "The Lander of Chandrayaan-2 was named Vikram after Dr Vikram A Sarabhai", PublishedAt = DateTime.Now
            };

            var actual = await repository.CreateNews(userId, news);

            Assert.IsAssignableFrom <int>(actual);
            Assert.Equal(102, actual);
        }
Ejemplo n.º 2
0
        public ActionResult Create(News news)
        {
            UserRepository repository = new UserRepository(DbQuery.ConnectionString);

            news.PublicationTime = DateTime.Now;
            var author = repository.GetUserById(news.UserId); //check this method;

            author.RememberMe = false;
            news.Author       = author;
            _db.CreateNews(news);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> CreateNews(NewsViewModel viewModel, HttpPostedFileBase file,
                                                    string redirectAction, string redirectController)
        {
            if (ModelState.IsValid)
            {
                var userId      = User.GetClaimValue(UserIdClaim);
                var createdNews = await _newsRepository.CreateNews(viewModel, userId, file);

                _notificationService.Create(NotificationType.Bells, EventType.NewsCreated, createdNews.Id);
            }

            if (!string.IsNullOrEmpty(redirectAction) && !string.IsNullOrEmpty(redirectController))
            {
                return(RedirectToAction(redirectAction, redirectController));
            }

            return(RedirectToAction("Details", "Business", new { id = viewModel.CompanyId }));
        }
Ejemplo n.º 4
0
 public NewsItemDto CreateNews(NewsItemInputModel news)
 {
     return(_newsRepo.CreateNews(news));
 }
Ejemplo n.º 5
0
 public int CreateNews(NewsItemInputModel newsItemInput)
 {
     return(_newsRepository.CreateNews(newsItemInput));
 }