This commit is contained in:
王炜翔 2024-10-10 22:42:58 +08:00
parent 5a2110550c
commit f878d849f8

View File

@ -50,7 +50,7 @@ namespace asg_form.Controllers
var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id == msg.invitedId); var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id == msg.invitedId);
if (userInvited == null) return Ok(new { code = 404, message = "用户未找到" }); if (userInvited == null) return Ok(new { code = 404, message = "用户未找到" });
var invitationRecord = await sb.T_Invitation.FindAsync(msg.invitedId); var invitationRecord = sb.T_Invitation.FirstOrDefault(c => c.user_id == msg.invitedId);
if (invitationRecord != null) if (invitationRecord != null)
{ {
@ -58,15 +58,21 @@ namespace asg_form.Controllers
{ {
return Ok(new { code = 409, message = "邀请已存在" }); return Ok(new { code = 409, message = "邀请已存在" });
} }
invitationRecord.my_request.Add((invitor_id: (int)userId, match_id: msg.matchId));
await sb.SaveChangesAsync();
} }
else
{
invitationRecord = new InviteBg invitationRecord = new InviteBg
{ {
user_id = msg.invitedId, user_id = msg.invitedId,
my_request = new List<(int, int)>() my_request = new List<(int, int)>()
}; };
invitationRecord.my_request.Add((invitor_id: (int)userId, match_id: msg.matchId)); invitationRecord.my_request.Add((invitor_id: (int)userId, match_id: msg.matchId));
sb.T_Invitation.Add(invitationRecord);
await sb.SaveChangesAsync(); await sb.SaveChangesAsync();
}
var data = new var data = new
{ {
invitedId = (int)userId, invitedId = (int)userId,