server/aspnetapp/Controllers/WebApi/BuyrUserController.cs

(开头部分) 3KB

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

#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using aspnetapp;
using aspnetapp.Models;

namespace aspnetapp.Controllers.WebApi
{
    [Route("api/[controller]")]
    [ApiController]
    public class BuyrUserController : ControllerBase
    {
        private readonly CounterContext _context;

        public BuyrUserController(CounterContext context)
        {
            _context = context;
        }

        // GET: api/BuyrUser
        [HttpGet]
        public async Task<ActionResult<IEnumerable<BuyrUserEntity>>> GetBuyrUsers()
        {
            return await _context.BuyrUsers.ToListAsync();
        }

        // GET: api/BuyrUser/5
        [HttpGet("{id}")]
        public async Task<ActionResult<BuyrUserEntity>> GetBuyrUserEntity(int id)
        {
            var buyrUserEntity = await _context.BuyrUsers.FindAsync(id);

            if (buyrUserEntity == null)
            {
                return NotFound();
            }

            return buyrUserEntity;
        }

        // PUT: api/BuyrUser/5
        [HttpPut("{id}")]
        public async Task<IActionResult> PutBuyrUserEntity(int id, BuyrUserEntity buyrUserEntity)
        {
            if (id != buyrUserEntity.Id)
            {
                return BadRequest();
            }

            _context.Entry(buyrUserEntity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
后面还有 62 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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