Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PostId,Title,Content,ImageUrl,DateOfPost,PostingUserID")] Post post)
        {
            if (id != post.PostId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(post);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostExists(post.PostId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostingUserID"] = new SelectList(_context.UserInfo, "UserInfoID", "UserInfoID", post.PostingUserID);
            return(View(post));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("UserInfoID,Name,Username,ProfilPictureUrl,NumberOfPosts,NumberOfComments,RegisterDate")] UserInfo userInfo)
        {
            if (id != userInfo.UserInfoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserInfoExists(userInfo.UserInfoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userInfo));
        }
        public async Task<IActionResult> Edit(int id, [Bind("CommentId,Content,DateOfComment")] Comment comment)
        {
            if (id != comment.CommentId)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.CommentId))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            return View(comment);
        }