wq
This commit is contained in:
		
							parent
							
								
									19ad65b51a
								
							
						
					
					
						commit
						87e3d2af81
					
				@ -123,7 +123,9 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        public class idToString
 | 
					        public class idToString
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            public string invitedName {  get; set; }
 | 
					            public string invitedName {  get; set; }
 | 
				
			||||||
            public string matchName { get; set; }
 | 
					            public string matchTeam1 { get; set; }
 | 
				
			||||||
 | 
					            public string matchTeam2 { get; set; }
 | 
				
			||||||
 | 
					            public string openTime { get; set; }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Route("api/v1/myInvitation")]
 | 
					        [Route("api/v1/myInvitation")]
 | 
				
			||||||
@ -135,32 +137,45 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            var user = await userManager.FindByIdAsync(Forid);
 | 
					            var user = await userManager.FindByIdAsync(Forid);
 | 
				
			||||||
            long userId = user.Id;
 | 
					            long userId = user.Id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int wrongPart = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            using (TestDbContext sub = new TestDbContext())
 | 
					            using (TestDbContext sub = new TestDbContext())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    wrongPart = 0;
 | 
				
			||||||
                    var query = sub.T_Invitation.FirstOrDefault(c => c.user_id == userId);
 | 
					                    var query = sub.T_Invitation.FirstOrDefault(c => c.user_id == userId);
 | 
				
			||||||
                    if (query != null)
 | 
					                    if (query != null)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					                        wrongPart = 1;
 | 
				
			||||||
                        List<idRequest> existingPairs = JsonSerializer.Deserialize<List<idRequest>>(json: query.my_request);
 | 
					                        List<idRequest> existingPairs = JsonSerializer.Deserialize<List<idRequest>>(json: query.my_request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        var TotalRecords = existingPairs.Count;
 | 
					                        var TotalRecords = 0;
 | 
				
			||||||
                        int skip = (page - 1) * limit;
 | 
					                        int skip = (page - 1) * limit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        List<idToString> Invintors = new List<idToString>();
 | 
					                        List<idToString> Invintors = new List<idToString>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        var queryForMatchName = sub.team_Games;
 | 
					                        wrongPart = 2;                        
 | 
				
			||||||
                        idToString dataAdd=new idToString();
 | 
					                        idToString dataAdd=new idToString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        wrongPart = 3;
 | 
				
			||||||
                        foreach (var pair in existingPairs)
 | 
					                        foreach (var pair in existingPairs)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id ==pair.invited_id);
 | 
					                            var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id ==pair.invited_id);
 | 
				
			||||||
 | 
					                            wrongPart = 5;
 | 
				
			||||||
                            dataAdd.invitedName = userInvited.chinaname;
 | 
					                            dataAdd.invitedName = userInvited.chinaname;
 | 
				
			||||||
                            var matchFind = queryForMatchName.FirstOrDefault(c => c.id == pair.match_id);
 | 
					                            wrongPart = 6;
 | 
				
			||||||
                            dataAdd.matchName = matchFind.team1_name + "VS" + matchFind.team2_name + " " + matchFind.opentime.ToString();
 | 
					                            var matchFind = sub.team_Games.FirstOrDefault(c => c.id == pair.match_id);
 | 
				
			||||||
 | 
					                            wrongPart = 7;
 | 
				
			||||||
 | 
					                            if (matchFind == null || matchFind.team1_name == null || matchFind.team2_name == null) continue;                          
 | 
				
			||||||
 | 
					                            dataAdd.matchTeam1 = matchFind.team1_name;
 | 
				
			||||||
 | 
					                            dataAdd.matchTeam2 = matchFind.team2_name;
 | 
				
			||||||
 | 
					                            wrongPart = 8;
 | 
				
			||||||
 | 
					                            dataAdd.openTime = matchFind.opentime.ToString();
 | 
				
			||||||
                            Invintors.Add(dataAdd);
 | 
					                            Invintors.Add(dataAdd);
 | 
				
			||||||
 | 
					                            TotalRecords++;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        wrongPart = 4;
 | 
				
			||||||
                        Invintors
 | 
					                        Invintors
 | 
				
			||||||
                            .Skip(skip)
 | 
					                            .Skip(skip)
 | 
				
			||||||
                            .Take(limit)
 | 
					                            .Take(limit)
 | 
				
			||||||
@ -174,15 +189,15 @@ namespace asg_form.Controllers
 | 
				
			|||||||
                        return Ok(new
 | 
					                        return Ok(new
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            code = 200,
 | 
					                            code = 200,
 | 
				
			||||||
                            message = "成功获取邀请",
 | 
					                            message = "成功获取邀请列表",
 | 
				
			||||||
                            result                           
 | 
					                            result                           
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return Ok(new { code = 200, message = "没有收到邀请" });
 | 
					                    return Ok(new { code = 200, message = "没有收到过邀请" });
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex)
 | 
					                catch (Exception ex)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    return Ok(new { code = 500, message = "服务器错误", details = ex.Message});
 | 
					                    return Ok(new { code = 500, message = "服务器错误", details = ex.Message,wrongPart});
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user