示例#1
0
 // GET: Posts/Create
 public IActionResult Create()
 {
     if (IsInRank("admin") | IsInRank("author"))
     {
         ViewData["CategoryId"] = new SelectList(_context.Set <Category>(), "Id", "Name");
         return(View());
     }
     return(RedirectToAction(nameof(Index)));
 }
示例#2
0
        // GET: Comments/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var comment = await _context.Comment.FindAsync(id);

            if (comment == null)
            {
                return(NotFound());
            }
            ViewData["PostId"] = new SelectList(_context.Set <Post>(), "Id", "Id", comment.PostId);
            ViewData["UserId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", comment.UserId);
            return(View(comment));
        }