src/NetCoreBBS/Areas/Admin/Controllers/NodeController.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NetCoreBBS.Entities;
using NetCoreBBS.Infrastructure;
using Microsoft.AspNetCore.Authorization;

namespace NetCoreBBS.Areas.Admin.Controllers
{
    [Area("Admin")]
    [Authorize("Admin")]
    public class NodeController : Controller
    {
        private DataContext _context;
        public NodeController(DataContext context)
        {
            _context = context;
        }
        // GET: Node
        public ActionResult Index()
        {
            var nodes = _context.TopicNodes.ToList();
            return View(nodes);
        }

        // GET: Node/Create
        public ActionResult Create(int parentid)
        {
            ViewBag.ParentId = parentid;
            return View();
        }

        // POST: Node/Create
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(TopicNode node)
        {
            try
            {
                node.CreateOn = DateTime.Now;
                _context.Add(node);
                _context.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Node/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: Node/Edit/5
后面还有 32 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。