public IActionResult Edit(int teamid, JuryEditTeamModel model) { var team = Service.QueryTeam(teamid).FirstOrDefault(); Service.UpdateTeam(team, model); Service.QueryTeam(teamid, true).FirstOrDefault(); return(Message( "Edit team", $"Team {team.TeamName} (t{teamid}) updated.", MessageType.Success)); }
public void UpdateTeam(Team team, JuryEditTeamModel model) { DbContext.AuditLogs.Add(new AuditLog { Type = AuditLog.TargetType.Contest, Time = DateTimeOffset.Now, Resolved = true, UserName = UserName, ContestId = Contest.ContestId, EntityId = team.TeamId, Comment = $"edit team t{team.TeamId} " + $"a{team.AffiliationId}->{model.AffiliationId}, " + $"c{team.CategoryId}->{model.CategoryId}, " + $"{team.TeamName}->{model.TeamName}", }); team.TeamName = model.TeamName; team.CategoryId = model.CategoryId; team.AffiliationId = model.AffiliationId; DbContext.Teams.Update(team); DbContext.SaveChanges(); }
public async Task <IActionResult> Edit(int teamid, JuryEditTeamModel model) { var team = await Context.FindTeamByIdAsync(teamid); if (team == null) { return(NotFound()); } await Context.UpdateTeamAsync(team, _ => new Team { TeamName = model.TeamName, AffiliationId = model.AffiliationId, CategoryId = model.CategoryId }); await HttpContext.AuditAsync("updated", $"{teamid}"); return(Message( title: "Edit team", message: $"Team {team.TeamName} (t{teamid}) updated.", type: BootstrapColor.success)); }
public async Task <IActionResult> Edit(int cid, int teamid, JuryEditTeamModel model) { var team = await Store.FindByIdAsync(cid, teamid); if (team == null) { return(NotFound()); } await Store.UpdateAsync(cid, teamid, team => new Team { TeamName = model.TeamName, AffiliationId = model.AffiliationId, CategoryId = model.CategoryId }); await HttpContext.AuditAsync("updated", $"{teamid}"); return(Message( title: "Edit team", message: $"Team {team.TeamName} (t{teamid}) updated.", type: MessageType.Success)); }