server/aspnetapp/Controllers/WebUI/HomeController.cs

(开头部分) 2KB

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

using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

namespace aspnetapp.Controllers.WebUI
{
    public class HomeController : Controller
    {
        private readonly CounterContext _context;

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

        public IActionResult Index()
        {
            return View();
        }

        public async Task<IActionResult> SetPhone(string wxid)
        {
            if (wxid == null)
            {
                return NotFound();
            }

            var buyrUserEntity = await _context.BuyrUsers.FirstOrDefaultAsync(s => s.WeChatOpenid == wxid).ConfigureAwait(false);
            if (buyrUserEntity == null)
            {
                return NotFound();
            }

            return View(buyrUserEntity);
        }

        [HttpPost]
        public async Task<IActionResult> SetPhone(int? id, string phone)
        {
            if (id == null)
            {
                return NotFound();
            }

            var buyrUserEntity = await _context.BuyrUsers.FindAsync(id);
            if (buyrUserEntity == null)
            {
                return NotFound();
            }
            buyrUserEntity.Phone = phone;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BuyrUserEntityExists(id.Value))
                {
                    return NotFound();
                }
后面还有 23 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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