Inheritance: API.ElevatedRequestImpl
Example #1
0
 public void UpdateTeam(string username)
 {
     Team team = null;
     try
     {
         team = GetTeamByUsername(username);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to find team " + username);
         var exception = new DataSubmissionException();
         exception.SubmitErrors.Add(new DataSubmitError()
         {
             FieldName = "username",
             ErrorCode = DataSubmitErrorCode.InvalidKey
         });
         throw exception;
     }
     ElevateToken token = GwupeClientAppContext.CurrentAppContext.Elevate("In order to update this team, please enter your current password.");
     var request = new UpdateTeamRq()
     {
         teamElement = new TeamElement()
         {
             avatarData = team.Avatar == null ? null : Convert.ToBase64String(team.Avatar),
             description = team.Description,
             email = team.Email,
             firstname = team.Firstname,
             location = team.Location,
             supporter = team.Supporter,
             user = team.Username
         },
         playerRequest = team.PlayerRequest,
         admin = team.Admin,
         securityKey = token.SecurityKey,
         tokenId = token.TokenId
     };
     try
     {
         var response = GwupeClientAppContext.CurrentAppContext.ConnectionManager.Connection
             .Request<UpdateTeamRq, UpdateTeamRs>(
                 request);
         GwupeClientAppContext.CurrentAppContext.PartyManager.AddUpdatePartyFromElement(response.teamElement);
     }
     catch (MessageException<UpdateTeamRs> ex)
     {
         Logger.Error("Failed to update team", ex);
         var exception = CompileDataSubmissionException(ex.Response.validationErrors);
         throw exception;
     }
 }