예제 #1
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (SamAccountName != null)
            {
                Response.error = Label.Get("error.firebase.alreadySubscribed", DTO.LngIsoCode);
                return(false);
            }


            if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken))
            {
                Response.error = Label.Get("error.authentication");
                return(false);
            }

            Subscriber_BSO bso = new Subscriber_BSO();


            if (bso.Create(Ado, DTO.SbrPreference, DTO.Uid, DTO.LngIsoCode))
            {
                //Calling GetSubscribers with readCache=false will cause the cache to be refreshed to include the new user
                bso.GetSubscribers(Ado, null, false);
                Response.data = JSONRPC.success;
                return(true);
            }
            Log.Instance.Debug("Can't create Subscription");
            Response.error = Label.Get("error.create");
            return(false);
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (SamAccountName != null)
            {
                Response.error = Label.Get("error.authentication");
                return(false);
            }


            if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken))
            {
                Response.error = Label.Get("error.authentication");
                return(false);
            }


            Subscriber_BSO sbso = new Subscriber_BSO();
            var            responseSubscriber = sbso.GetSubscribers(Ado, DTO.Uid);



            if (responseSubscriber.Count > 0)
            {
                Response.data = responseSubscriber.FirstOrDefault();
                return(true);
            }
            return(false);
        }
예제 #3
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Subscriber_BSO sbso     = new Subscriber_BSO();
            var            response = sbso.GetSubscribers(Ado, DTO.Uid);

            if (response.Count > 0)
            {
                Response.data = response;
                return(true);
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            string subscriberUserId;

            //A local/ad user can't delete themselves
            //However an admin user can delete a subscriber
            if (SamAccountName != null)
            {
                if (IsAdministrator() && DTO.Uid != null)
                {
                    subscriberUserId = DTO.Uid;
                }
                else
                {
                    Response.error = Label.Get("error.authentication");
                    return(false);
                }
            }

            else
            {
                //The subscriber is attempting to delete themselves

                if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken))
                {
                    Response.error = Label.Get("error.authentication");
                    return(false);
                }
                subscriberUserId = DTO.Uid;
            }

            Subscriber_BSO bso = new Subscriber_BSO();



            if (bso.Delete(Ado, subscriberUserId))
            {
                //Delete the user also from Firebase
                API.Firebase.DeleteUser(subscriberUserId);

                //Refresh the cache of subscriber keys (for throttling)
                new Subscriber_BSO().RefreshSubscriberKeyCache(Ado);

                //Refresh the cache of subscribers (for reading)
                bso.GetSubscribers(Ado, null, false);
                Response.data = JSONRPC.success;
                return(true);
            }
            Log.Instance.Debug("Can't delete Subscriber");
            Response.error = Label.Get("error.delete");
            return(false);
        }
예제 #5
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (Common.FirebaseId == null && SamAccountName == null)
            {
                Response.error = Label.Get("error.authentication");
                return(false);
            }

            using (eMail email = new eMail())
            {
                string Body    = "";
                string Subject = "";

                Body          = Label.Get("email.body.subscription-notification", DTO.LngIsoCode);
                Subject       = Label.Get("email.subject.subscription-notification", DTO.LngIsoCode);
                email.Body    = Body;
                email.Subject = Subject;

                // Get user from FirebaseId
                Subscriber_BSO sbso = new Subscriber_BSO();
                var            user = sbso.GetSubscribers(Ado, Common.FirebaseId);

                if (user.FirstOrDefault() == null)
                {
                    Log.Instance.Debug("Cannot send notification because email address is null");
                    Response.error = Label.Get("error.notification");
                    return(false);
                }

                // Get email address from user
                string emailAddress = user.FirstOrDefault().CcnEmail;
                email.To.Add(emailAddress);
                Log.Instance.Debug($"Send notification to {emailAddress}");
                email.Send();
            }
            return(true);
        }