示例#1
0
        public ProfileDTO BuildProfileDTO(NixTeamAppointmentResponse data)
        {
            ProfileDTO result = new ProfileDTO()
            {
                About            = data.About,
                MySports         = data.MySports,
                Children         = data.Children,
                Id               = data.Id,
                Type             = data.Type,
                FirstName        = data.FirstName,
                LastName         = data.LastName,
                DisplayName      = data.DisplayName,
                ShortId          = data.ShortId,
                DateOfBirth      = data.DateOfBirth,
                Availability     = data.Availability,
                LastSeen         = data.LastSeen,
                ParentId         = data.ParentId,
                ChildUserName    = data.ChildUserName,
                ChildPassword    = data.ChildPassword,
                Contact          = data.Contact,
                Address          = data.Address,
                BackgroundImage  = data.BackgroundImage,
                Avatar           = data.Avatar,
                BrandImage       = data.BrandImage,
                IsEmailConfirmed = data.IsEmailConfirmed,
                Media            = data.Media
            };

            return(result);
        }
示例#2
0
        public Task <ProfileDTO> NixTeamAppointmentAsync(long targetTeamId, CancellationTokenSource cancellationTokenSource) =>
        Task <ProfileDTO> .Run(async() => {
            if (!CrossConnectivity.Current.IsConnected)
            {
                throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION);
            }

            ProfileDTO resultProfile = null;

            NixTeamAppointmentRequest nixTeamAppointmentRequest = new NixTeamAppointmentRequest()
            {
                AccessToken = GlobalSettings.Instance.UserProfile.AccesToken,
                Url         = string.Format(GlobalSettings.Instance.Endpoints.TeamEndPoints.NixTeamAppointmentRequest, targetTeamId)
            };

            NixTeamAppointmentResponse nixTeamAppointmentResponse = null;

            try {
                nixTeamAppointmentResponse = await _requestProvider.DeleteAsync <NixTeamAppointmentRequest, NixTeamAppointmentResponse>(nixTeamAppointmentRequest);

                if (nixTeamAppointmentResponse != null)
                {
                    resultProfile = _profileFactory.BuildProfileDTO(nixTeamAppointmentResponse);
                }
                else
                {
                    throw new InvalidOperationException(TeamService.NIX_APPOINTMENT_TO_THE_TEAM_COMMON_ERROR_MESSAGE);
                }
            }
            catch (ServiceAuthenticationException exc) {
                _identityUtilService.RefreshToken();

                throw exc;
            }
            catch (HttpRequestExceptionEx exc) {
                nixTeamAppointmentResponse = JsonConvert.DeserializeObject <NixTeamAppointmentResponse>(exc.Message);

                string output = string.Format("{0}",
                                              nixTeamAppointmentResponse.Relation?.FirstOrDefault());

                output = (string.IsNullOrWhiteSpace(output) || string.IsNullOrEmpty(output)) ? TeamService.NIX_APPOINTMENT_TO_THE_TEAM_COMMON_ERROR_MESSAGE : output;

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

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