コード例 #1
0
        public async Task <IActionResult> Create([Bind("Id,userName,gender,alias,website,socialWebsite,email,dob")] UserModel userModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,userName,email,profilePicUrl,friendsEmail")] SocialModel socialModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(socialModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(socialModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Headline,Content")] BlogModel blogModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogModel));
        }
コード例 #4
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,Name,Content,AuthorEmail")] BlogPost blogPost)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogPost);
                await _context.SaveChangesAsync();

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