server/aspnetapp/Controllers/WebUI/CategoriesController.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
#nullable disable
using aspnetapp.Helper;
using aspnetapp.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace aspnetapp.Controllers.WebUI
{
public class CategoriesController : Controller
{
private readonly CounterContext _context;
public CategoriesController(CounterContext context)
{
_context = context;
}
// GET: Categories
public async Task<IActionResult> Index()
{
return View(await _context.CategoryEntity.ToListAsync());
}
// GET: Categories/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var categoryEntity = await _context.CategoryEntity
.FirstOrDefaultAsync(m => m.Id == id);
if (categoryEntity == null)
{
return NotFound();
}
return View(categoryEntity);
}
// GET: Categories/Create
public IActionResult Create()
{
ViewBag.Ordertype = typeof(EnumCode.OrderType)._ToSelectListItems(0);
return View();
}
// POST: Categories/Create
[HttpPost]
public async Task<IActionResult> Create(CategoryEntity categoryEntity)
{
if (ModelState.IsValid)
{
_context.Add(categoryEntity);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(categoryEntity);
后面还有 93 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。