public int PopulateDatabase() { if (!_tweetContext.Tweets.Any()) { _tweetContext.Add(new Tweet { Id = 1, Descricao = "Tweet test 1", Imagem = "Image test 1", Usuario = "User test 1", Ativo = true }); _tweetContext.Add(new Tweet { Id = 2, Descricao = "Tweet test 2", Imagem = "Image test 2", Usuario = "User test 2", Ativo = true }); _tweetContext.Add(new Tweet { Id = 3, Descricao = "Tweet test 3", Imagem = "Image test 3", Usuario = "User test 3", Ativo = true }); } _tweetContext.SaveChanges(); return(_tweetContext.Tweets.Count()); }
public async Task <IActionResult> Create([Bind("Id,Content,Date")] Tweet tweet) { if (ModelState.IsValid) { _context.Add(tweet); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tweet)); }