Exemplo n.º 1
0
 public async Task<IActionResult> Create([Bind("CommentId,Content,DateOfComment")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         _context.Add(comment);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(comment);
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("UserInfoID,Name,Username,ProfilPictureUrl,NumberOfPosts,NumberOfComments,RegisterDate")] UserInfo userInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userInfo));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("PostId,Title,Content,ImageUrl,DateOfPost,PostingUserID")] Post post)
        {
            if (ModelState.IsValid)
            {
                _context.Add(post);
                await _context.SaveChangesAsync();

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