示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Blah,WroteDate,Likes")] Witter witter)
        {
            if (ModelState.IsValid)
            {
                witter.WroteDate = DateTime.Now;
                _context.Add(witter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(witter));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Name,FriendsSince,Job,Portrait")] Friend friend)
        {
            if (ModelState.IsValid)
            {
                friend.FriendsSince = DateTime.Now;
                _context.Add(friend);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(friend));
        }