1
This commit is contained in:
parent
d4c12789a9
commit
7976d31b1a
@ -56,14 +56,7 @@ namespace asg_form.Controllers
|
|||||||
{
|
{
|
||||||
public int invitedId { get; set; }
|
public int invitedId { get; set; }
|
||||||
public int matchId { get; set; }
|
public int matchId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool outOfTime(DateTime d)
|
|
||||||
{
|
|
||||||
DateTime currentTime = DateTime.Now;
|
|
||||||
|
|
||||||
if (currentTime > d.AddDays(1)) return true; else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Route("api/v1/Invite")]
|
[Route("api/v1/Invite")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -74,7 +67,7 @@ namespace asg_form.Controllers
|
|||||||
string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||||
var user = await userManager.FindByIdAsync(Invitorid);
|
var user = await userManager.FindByIdAsync(Invitorid);
|
||||||
long userId = user.Id;
|
long userId = user.Id;
|
||||||
if (user.officium != "Commentator" || !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" });
|
if (user.officium != "Commentator" || this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" });
|
||||||
using (TestDbContext sb = new TestDbContext())
|
using (TestDbContext sb = new TestDbContext())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -146,12 +139,7 @@ namespace asg_form.Controllers
|
|||||||
|
|
||||||
var invited = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.invited_id);
|
var invited = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.invited_id);
|
||||||
var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id);
|
var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id);
|
||||||
if (outOfTime(theGame.opentime))
|
if (theGame == null) return Ok(new { code = 200, message = "没有比赛资料" });
|
||||||
{
|
|
||||||
sub.team_Games.Remove(theGame);
|
|
||||||
sub.SaveChanges();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var addData = new InviteForUsers
|
var addData = new InviteForUsers
|
||||||
{
|
{
|
||||||
id = record.id,
|
id = record.id,
|
||||||
@ -213,12 +201,8 @@ namespace asg_form.Controllers
|
|||||||
{
|
{
|
||||||
var invitor = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.user_id);
|
var invitor = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.user_id);
|
||||||
var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id);
|
var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id);
|
||||||
if (outOfTime(theGame.opentime))
|
if (invitor == null) return Ok(new { code = 200, message = "被邀请者不存在了" });
|
||||||
{
|
if (theGame == null) return Ok(new { code = 200, message = "没有比赛资料" });
|
||||||
sub.team_Games.Remove(theGame);
|
|
||||||
sub.SaveChanges();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var addData = new BeInviteForUsers
|
var addData = new BeInviteForUsers
|
||||||
{
|
{
|
||||||
id = record.id,
|
id = record.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user