コード例 #1
0
 private GameDTO BuildGame(UpdateGameResponse data)
 {
     try {
         return(new GameDTO()
         {
             Assignments = data.Assignments,
             TeamId = data.TeamId,
             DurationInMinutes = data.DurationInMinutes,
             Id = data.Id,
             IsCanceled = data.IsCanceled,
             IsTimeTbd = data.IsTimeTbd,
             Location = data.Location,
             LocationDetails = data.LocationDetails,
             MinutesToArriveEarly = data.MinutesToArriveEarly,
             Notes = data.Notes,
             NotForStandings = data.NotForStandings,
             Opponent = data.Opponent,
             StartDate = data.StartDate,
             Type = data.Type,
             Uniform = data.Uniform
         });
     }
     catch (Exception exc) {
         throw new InvalidOperationException("SchedulingService BuildGame()", exc);
     }
 }
コード例 #2
0
        public Task <GameDTO> UpdateGameAsync(ManageGameDataModel updateGameDataModel, long gameId, CancellationTokenSource cancellationTokenSource) =>
        Task <GameDTO> .Run(async() => {
            if (!CrossConnectivity.Current.IsConnected)
            {
                throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION);
            }

            GameDTO updatedGame = null;

            UpdateGameRequest updateGameRequest = new UpdateGameRequest()
            {
                AccessToken = GlobalSettings.Instance.UserProfile.AccesToken,
                Data        = updateGameDataModel,
                Url         = string.Format(GlobalSettings.Instance.Endpoints.ScheduleEndpoints.UpdateGame, gameId)
            };

            try {
                UpdateGameResponse updateGameResponse = await _requestProvider.PostAsync <UpdateGameRequest, UpdateGameResponse>(updateGameRequest);

                if (updateGameResponse != null)
                {
                    updatedGame = BuildGame(updateGameResponse);
                }
                else
                {
                    throw new InvalidOperationException(UPDATE_GAME_COMMON_ERROR_MESSAGE);
                }
            }
            catch (HttpRequestExceptionEx exc) {
                CreateUpdateGameBadResponse createGameBadResponse = JsonConvert.DeserializeObject <CreateUpdateGameBadResponse>(exc.Message);

                string output = string.Format("{0} {1} {2} {3} {4} {5} {6}",
                                              createGameBadResponse.Errors?.FirstOrDefault(),
                                              createGameBadResponse.LocationId?.FirstOrDefault(),
                                              createGameBadResponse.OpponentId?.FirstOrDefault(),
                                              createGameBadResponse.TeamId?.FirstOrDefault(),
                                              createGameBadResponse.Type?.FirstOrDefault(),
                                              createGameBadResponse.DurationInMinutes?.FirstOrDefault(),
                                              createGameBadResponse.MinutesToArriveEarly?.FirstOrDefault());

                output = (string.IsNullOrWhiteSpace(output) || string.IsNullOrEmpty(output)) ? UPDATE_GAME_COMMON_ERROR_MESSAGE : output.Trim();

                throw new InvalidOperationException(output);
            }
            catch (Exception exc) {
                Crashes.TrackError(exc);

                throw;
            }

            return(updatedGame);
        }, cancellationTokenSource.Token);
コード例 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateGameResponse response = new UpdateGameResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Game", targetDepth))
                {
                    var unmarshaller = GameDetailsUnmarshaller.Instance;
                    response.Game = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }