57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
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<Role> roleManager;
|
|
private readonly UserManager<User> userManager;
|
|
public InviteReferee(
|
|
RoleManager<Role> roleManager, UserManager<User> userManager)
|
|
{
|
|
|
|
this.roleManager = roleManager;
|
|
this.userManager = userManager;
|
|
}
|
|
|
|
public class InviteBg
|
|
{
|
|
public int id { get; set; }
|
|
public int userId { get; set; }
|
|
public List<int> myRequest { get; set; }
|
|
|
|
}
|
|
|
|
[Route("api/v1/Invite")]
|
|
[HttpGet]
|
|
[Authorize]
|
|
public async Task<ActionResult<object>> 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();
|
|
}
|
|
}
|
|
}
|
|
}
|