public async Task register_device_notification_Hub()
    {
        NotificationHubRepository repo = new NotificationHubRepository(notificationHubConString);

        var registration = new MobileDeviceInstallationNotificationHub()
        {
            InstallationId = "instaltestid",
            Platform       = "gcm",
            PushChannel    = "testToken",
            Tags           = new List <string> {
                "tag1", "tag2"
            },
            Templates = new System.Collections.Generic.Dictionary <string, NotificationPushTemplate>
            {
                { "key1", new NotificationPushTemplate()
                  {
                      Body = "{\"data\":{\"message\":\"Notification Hub test notification\"}}"
                  } }
            }
        };

        await repo.RegisterMobileDevice(registration);

        // await repo.SendNotification("{\"data\":{\"message\":\"Notification Hub test notification\"}}", "testtag");
    }
        public async Task <IActionResult> RegisterDevice([FromBody] MobileDeviceInstallationNotificationHub deviceInstallation)
        {
            try
            {
                logger.LogInformation("Register Device in Notification Hub id- {0}", deviceInstallation.InstallationId);
                await _notificationHubRepo.RegisterMobileDevice(deviceInstallation);

                return(Ok());
            }
            catch (Exception e)
            {
                logger.LogError(e, "Register Device in Notification Hub- Exception {message}", e.Message);
                throw;
            }
        }
        public async Task <Boolean> RegisterMobileDevice(MobileDeviceInstallationNotificationHub deviceUpdate)
        {
            Dictionary <string, InstallationTemplate> templates = new Dictionary <string, InstallationTemplate>();

            foreach (var t in deviceUpdate.Templates)
            {
                templates.Add(t.Key, new InstallationTemplate {
                    Body = t.Value.Body
                });
            }
            Installation installation = new Installation()
            {
                InstallationId = deviceUpdate.InstallationId,
                PushChannel    = deviceUpdate.PushChannel,
                Tags           = deviceUpdate.Tags,
                Templates      = templates
            };

            switch (deviceUpdate.Platform)
            {
            case "apns":
                installation.Platform = NotificationPlatform.Apns;
                break;

            case "gcm":
                installation.Platform = NotificationPlatform.Gcm;
                break;

            default:
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            installation.Tags = new List <string>(deviceUpdate.Tags);
            try
            {
                await _hubClient.CreateOrUpdateInstallationAsync(installation);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }