Пример #1
0
 private static DataSubmissionException CompileDataSubmissionException(List<String> validationErrors)
 {
     var exception = new DataSubmissionException();
     if (validationErrors != null)
     {
         if (validationErrors.Contains(SignupRs.SignupErrorEmailAddressInUse))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "email",
                 ErrorCode = DataSubmitErrorCode.InUse
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorEmailAddressInvalid))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "email",
                 ErrorCode = DataSubmitErrorCode.EmailInvalid
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorUserExists))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "username",
                 ErrorCode = DataSubmitErrorCode.InUse
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorPasswordComplexity))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "password",
                 ErrorCode = DataSubmitErrorCode.NotComplexEnough
             });
         }
     }
     return exception;
 }
Пример #2
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;
     }
 }