public void Delete(int id) { MatchLog matchLog = _context.MatchLog.Single(p => p.Id == id); _context.MatchLog.Remove(matchLog); _context.SaveChanges(); }
public async Task <ActionResult <ApiResult <string> > > Record([FromBody] MatchLog log, [FromQuery] double?hostScore, [FromQuery] double?visitorScore) { await Service.RecordMatchAsync(log); var match = await Service.GetAsync <Match>(log.MatchId); if (hostScore.HasValue && visitorScore.HasValue) { match.HostScore = hostScore.Value; match.VisitorScore = visitorScore.Value; await Service.UpdateAsync(match, nameof(match.HostScore), nameof(match.VisitorScore)); } return(new ApiResult <string> { Result = "ok" }); }
public async Task <MatchLog> ChangeStatisticianAsync(int teamId, UserInfo user) { var team = await GetAsync <Team>(teamId); var oldUser = team.UserInfoId; team.UserInfoId = user.ID; await UpdateAsync(team, nameof(team.UserInfoId)); await SetRelativeEntitysAsync <Match, UserInfo>(user.ID, team.MatchId); // 保存用户参与过的比赛 var log = new MatchLog { LogTime = DateTime.Now, Content = $"{team.Name}更换统计员:{user.Name ?? user.NickName}", Category = MatchLogCategory.ChangeStatistician, MatchId = team.MatchId, UserInfoId = oldUser }; await AddAsync(log); await SetRelativeEntitysAsync <MatchLog, Match>(team.MatchId, log); // 保存比赛日志与比赛之间的关系 return(null); }
public async Task RecordMatchAsync(MatchLog log) { await AddAsync(log); await SetRelativeEntitysAsync <MatchLog, Match>(log.MatchId, log); }