コード例 #1
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));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("AuthorId,GivenName,Surname,Email")] Author author)
        {
            if (ModelState.IsValid)
            {
                _context.Add(author);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("UserId,RealName,Alias,Birthday")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("SocialId,Website,SocialMediaURL,ActiveSince,UserId")] Social social)
        {
            if (ModelState.IsValid)
            {
                _context.Add(social);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.User, "UserId", "UserId", social.UserId);
            return(View(social));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("BlogId,BlogTitle,BlogUrl,BlogDescription,AuthorId")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"] = new SelectList(_context.Author, "AuthorId", "AuthorId", blog.AuthorId);
            return(View(blog));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("PostId,PostTitle,PostContent,BlogId")] Post post)
        {
            if (ModelState.IsValid)
            {
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BlogId"] = new SelectList(_context.Blog, "BlogId", "BlogId", post.BlogId);
            return(View(post));
        }