예제 #1
0
        public string Unregister(PushUserServiceRequest pushUserUnregister)
        {
            // Authenticate.
            var userId = this.UserId;

            try
            {
                this.pushUserEndpointsRepository.RemovePushUserEndpoint(new PushUserEndpoint(pushUserUnregister.ApplicationId, pushUserUnregister.DeviceId)
                {
                    UserId = userId
                });
            }
            catch (Exception exception)
            {
                throw new WebFaultException <string>(
                          string.Format(CultureInfo.InvariantCulture, "There was an error unregistering the Push Notification Endpoint: {0}", exception.Message),
                          HttpStatusCode.InternalServerError);
            }

            return("Success");
        }
예제 #2
0
        public string Register(PushUserServiceRequest pushUserRegister)
        {
            // Authenticate.
            var userId = this.UserId;

            try
            {
                var pushUserEndpoint = this.pushUserEndpointsRepository.GetPushUserByApplicationAndDevice(pushUserRegister.ApplicationId, pushUserRegister.DeviceId);
                if (pushUserEndpoint == null)
                {
                    var newPushUserEndPoint = new PushUserEndpoint(pushUserRegister.ApplicationId, pushUserRegister.DeviceId)
                    {
                        ChannelUri = pushUserRegister.ChannelUri.ToString(), UserId = userId
                    };
                    this.pushUserEndpointsRepository.AddPushUserEndpoint(newPushUserEndPoint);
                }
                else
                {
                    // If the user did not change the channel URI, then, there is nothing to update, otherwise, set the new connection status
                    if (!pushUserEndpoint.ChannelUri.Equals(pushUserRegister.ChannelUri.ToString()) ||
                        !pushUserEndpoint.UserId.Equals(userId))
                    {
                        // Update che channelUri for the UserEndpoint and reset status fields.
                        pushUserEndpoint.ChannelUri = pushUserRegister.ChannelUri.ToString();
                        pushUserEndpoint.UserId     = userId;
                    }

                    this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint);
                }
            }
            catch (Exception exception)
            {
                throw new WebFaultException <string>(
                          string.Format(CultureInfo.InvariantCulture, "There was an error registering the Push Notification Endpoint: {0}", exception.Message),
                          HttpStatusCode.InternalServerError);
            }

            return("Success");
        }
        public string Unregister(PushUserServiceRequest pushUserUnregister)
        {
            // Authenticate.
            var userId = this.UserId;

            try
            {
                this.pushUserEndpointsRepository.RemovePushUserEndpoint(new PushUserEndpoint() { ApplicationId = pushUserUnregister.ApplicationId, DeviceId = pushUserUnregister.DeviceId, UserId = userId });
            }
            catch (Exception exception)
            {
                throw new WebFaultException<string>(
                    string.Format(CultureInfo.InvariantCulture, "There was an error unregistering the Push Notification Endpoint: {0}", exception.Message),
                    HttpStatusCode.InternalServerError);
            }

            return "Success";
        }
        public string Register(PushUserServiceRequest pushUserRegister)
        {
            // Authenticate.
            var userId = this.UserId;

            try
            {
                var pushUserEndpoint = this.pushUserEndpointsRepository.GetPushUserByApplicationAndDevice(pushUserRegister.ApplicationId, pushUserRegister.DeviceId);
                if (pushUserEndpoint == null)
                {
                    var newPushUserEndPoint = new PushUserEndpoint() { ApplicationId = pushUserRegister.ApplicationId, DeviceId = pushUserRegister.DeviceId, ChannelUri = pushUserRegister.ChannelUri.ToString(), UserId = userId };
                    this.pushUserEndpointsRepository.AddPushUserEndpoint(newPushUserEndPoint);
                }
                else
                {
                    // If the user did not change the channel URI, then, there is nothing to update, otherwise, set the new connection status
                    if (!pushUserEndpoint.ChannelUri.Equals(pushUserRegister.ChannelUri.ToString()) ||
                        !pushUserEndpoint.UserId.Equals(userId))
                    {
                        // Update che channelUri for the UserEndpoint and reset status fields.
                        pushUserEndpoint.ChannelUri = pushUserRegister.ChannelUri.ToString();
                        pushUserEndpoint.UserId = userId;
                    }

                    this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint);
                }
            }
            catch (Exception exception)
            {
                throw new WebFaultException<string>(
                    string.Format(CultureInfo.InvariantCulture, "There was an error registering the Push Notification Endpoint: {0}", exception.Message),
                    HttpStatusCode.InternalServerError);
            }

            return "Success";
        }