using Masuit.Tools; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Security.Claims; namespace asg_form.Controllers { public class InviteReferee : ControllerBase { private readonly RoleManager roleManager; private readonly UserManager userManager; public InviteReferee( RoleManager roleManager, UserManager userManager) { this.roleManager = roleManager; this.userManager = userManager; } public class InviteBg { public int id { get; set; } public int userId { get; set; } public List myRequest { get; set; } } [Route("api/v1/Invite")] [HttpGet] [Authorize] public async Task> GetReferee([FromBody] long Inviteeid) { string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; var user = await userManager.FindByIdAsync(Invitorid); long userId = user.Id; using (TestDbContext sb = new TestDbContext()) { try { //var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id == Inviteeid); //if (userInvited != null) return Ok(new { code = 404, message = "用户未找到" }); var query = await sb.T_Invitation.FindAsync(Inviteeid); }catch (Exception ex) { return Ok(new { code = 500, message = "服务器错误", details = ex.Message }); } return Ok(); } } } }