Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,UserName")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Text,UserId,TimeStamp")] Tweet tweet)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tweet);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", tweet.UserId);
            return(View(tweet));
        }