public async Task <PushSettings> NotificationDeleteAsync(
     string registrationId,
     NotificationMessageSource notificationSource,
     bool useGlobalMobileApiV1 = false)
 {
     return(await this.SendAsync <PushSettings>(HttpMethod.Delete, "Registration", new Dictionary <string, string>()
     {
         {
             nameof(registrationId),
             registrationId
         },
         {
             nameof(notificationSource),
             notificationSource.ToString()
         },
         {
             "NotificationEnvironment",
             "Ellenorzo_Xamarin"
         },
         {
             "SchoolYearId",
             this.GetSchoolYearId()
         }
     }, useGlobalMobileApiV1, (string)null));
 }
 public async Task <PushSettings> NotificationUpdateAsync(
     string registrationId,
     int notificationType,
     NotificationMessageSource notificationSource,
     string handle)
 {
     return(await this.SendAsync <PushSettings>(HttpMethod.Put, "Registration", new Dictionary <string, string>()
     {
         {
             "RegistrationId",
             registrationId
         },
         {
             "NotificationType",
             notificationType.ToString()
         },
         {
             "NotificationSource",
             notificationSource.ToString()
         },
         {
             "NotificationEnvironment",
             "Ellenorzo_Xamarin"
         },
         {
             "Handle",
             handle
         },
         {
             "SchoolYearId",
             this.GetSchoolYearId()
         }
     }, false, (string)null));
 }
        public async Task <bool> NotificationRegistrationAsync(ProfileRealm profile)
        {
            try
            {
                if (!this._pushNotificationPlatformSpecificService.IsPushNotificationEnabledByDevice())
                {
                    throw new DisabledPushByDeviceException().SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 168);
                }
                string platform = this._pushNotificationHandler.Platform.ToString();
                NotificationMessageType notificationType = NotificationMessageType.All;
                string handle = this._pushNotificationHandler.Token;
                NotificationMessageSource notificationSource = NotificationMessageSource.Kreta;
                TokenData tokenData = this._secureStore.GetTokenData(profile.Id);
                if (tokenData.ExpiresAt <= DateTime.Now)
                {
                    tokenData = await((IAuthDbDataService)Mvx.get_IoCProvider().Resolve <IAuthDbDataService>()).RefreshToken(profile);
                }
                if (tokenData == null)
                {
                    return(false);
                }
                this._tokenInfoRepository.AddOrUpdate(new TokenInfoRealmMapper().To((Ekreta.Mobile.Core.Models.TokenInfo)JsonConvert.DeserializeObject <Ekreta.Mobile.Core.Models.TokenInfo>(TokenDecoder.Decode(tokenData.AccessToken))), (Action <TokenInfoRealm>)null);
                Ekreta.Mobile.Core.Models.PushNotification.PushSettings pushSettings = await this._globalMobileApi.NotificationRegistrationAsync(profile.TokenInfo.InstituteCode, profile.TokenInfo.InstituteUserId, profile.TokenInfo.TutelaryId, platform, handle, (UserRoles)profile.TokenInfo.Role, notificationSource, (int)notificationType, profile.Id);

                PushSettingsRealm pushSettingsRealm = new PushSettingsRealmMapper().To(pushSettings);
                if (pushSettingsRealm != null)
                {
                    this._pushSettingsRepository.AddOrUpdate(pushSettingsRealm, (Action <PushSettingsRealm>)(ps =>
                    {
                        ps.NotificationTypes = (int)notificationType;
                        ps.FirstTimePushRun  = true;
                        ps.UpdateEugyintezes = true;
                        ps.Token             = handle;
                    }));
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings = pushSettingsRealm));
                }
                else if (profile.PushSettings != null)
                {
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings.FirstTimePushRun = true));
                }
                else
                {
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings = new PushSettingsRealm()
                    {
                        FirstTimePushRun = true
                    }));
                }
                return(pushSettings != null);
            }
            catch (DisabledPushByDeviceException ex)
            {
                ex.SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 243);
                throw;
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, "ProfileDataService.NotificationRegistrationAsync", "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 75);
                return(false);
            }
        }
 public async Task <PushSettings> NotificationRegistrationAsync(
     string instituteCode,
     int instituteUserId,
     string tutelaryId,
     string platform,
     string handle,
     UserRoles notificationRole,
     NotificationMessageSource notificationSource,
     int notificationType,
     string profileId)
 {
     return(await this.SendAsync <PushSettings>(HttpMethod.Post, "Registration", new Dictionary <string, string>()
     {
         {
             "InstituteCode",
             instituteCode
         },
         {
             "InstituteUserId",
             instituteUserId.ToString()
         },
         {
             "TutelaryId",
             tutelaryId
         },
         {
             "Platform",
             platform
         },
         {
             "NotificationType",
             "All"
         },
         {
             "NotificationRole",
             notificationRole.ToString()
         },
         {
             "NotificationSource",
             notificationSource.ToString()
         },
         {
             "NotificationEnvironment",
             "Ellenorzo_Xamarin"
         },
         {
             "SchoolYearId",
             this.GetSchoolYearId()
         },
         {
             "Handle",
             handle
         }
     }, false, profileId));
 }