Esempio n. 1
0
 private EventDTO BuildEvent(UpdateEventResponse data)
 {
     try {
         return(new EventDTO()
         {
             Assignments = data.Assignments,
             TeamId = data.TeamId,
             DurationInMinutes = data.DurationInMinutes,
             Id = data.Id,
             IsCanceled = data.IsCanceled,
             IsTimeTbd = data.IsTimeTbd,
             Location = data.Location,
             LocationDetails = data.LocationDetails,
             Notes = data.Notes,
             StartDate = data.StartDate,
             Name = data.Name,
             RepeatingType = data.RepeatingType,
             RepeatsUntil = data.RepeatsUntil,
             ShortLabel = data.ShortLabel
         });
     }
     catch (Exception exc) {
         throw new InvalidOperationException("SchedulingService BuildEvent()", exc);
     }
 }
Esempio n. 2
0
        public Task <EventDTO> UpdateEventAsync(ManageEventDataModel updateEventDataModel, long eventId, CancellationTokenSource cancellationTokenSource) =>
        Task <GameDTO> .Run(async() => {
            if (!CrossConnectivity.Current.IsConnected)
            {
                throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION);
            }

            EventDTO updatedEvent = null;

            UpdateEventRequest updateEventRequest = new UpdateEventRequest()
            {
                AccessToken = GlobalSettings.Instance.UserProfile.AccesToken,
                Data        = updateEventDataModel,
                Url         = string.Format(GlobalSettings.Instance.Endpoints.ScheduleEndpoints.UpdateEvent, eventId)
            };

            try {
                UpdateEventResponse updateEventResponse = await _requestProvider.PostAsync <UpdateEventRequest, UpdateEventResponse>(updateEventRequest);

                if (updateEventResponse != null)
                {
                    updatedEvent = BuildEvent(updateEventResponse);
                }
                else
                {
                    throw new InvalidOperationException(UPDATE_EVENT_COMMON_ERROR_MESSAGE);
                }
            }
            catch (HttpRequestExceptionEx exc) {
                UpdateEventResponse createGameBadResponse = JsonConvert.DeserializeObject <UpdateEventResponse>(exc.Message);

                string output = string.Format("{0}",
                                              createGameBadResponse.Errors?.FirstOrDefault());

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

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

                throw;
            }

            return(updatedEvent);
        }, cancellationTokenSource.Token);