public SubscriberRecord TryRegisterConfirmSubscriber(string keySubscribe)
        {
            string parametri = "";

            // Ritorno al Nonce originale
            keySubscribe = System.Web.HttpUtility.HtmlDecode(keySubscribe.Replace('_', '+').Replace('-', '/'));

            // Verifico che non sia passata più di 1 ora dalla richiesta di Unsubscribe
            bool decryptOk = _commonServices.DecryptNonce(keySubscribe, out parametri);

            if (!decryptOk)
            {
                _orchardServices.Notifier.Error(T("Subscribe impossible. Please try again."));
                return(null);
            }

            string[] infoKey  = parametri.Split('&');
            string[] parEmail = infoKey[0].Split('=');
            string   email    = parEmail[1];

            var subs = _repositorySubscribers.Table.Where(w => w.Email == email && w.SubscriptionKey == keySubscribe).SingleOrDefault();

            if (subs == null)
            {
                _orchardServices.Notifier.Error(T("Subscriber not found!"));
                return(null);
            }

            if (subs.Confirmed)
            {
                _orchardServices.Notifier.Error(T("Email already registered!"));
                return(null);
            }

            subs.SubscriptionKey  = null;
            subs.ConfirmationDate = DateTime.Now;
            subs.Confirmed        = true;

            try {
                _repositorySubscribers.Update(subs);
                return(subs);
            }
            catch (Exception ex) {
                _orchardServices.Notifier.Error(T(ex.Message));
                return(null);
            }
        }
Exemple #2
0
        public bool UnsubscribeMail(string keyUnsubscribe)
        {
            string parametri = "";

            // Ritorno al Nonce originale
            keyUnsubscribe = System.Web.HttpUtility.HtmlDecode(keyUnsubscribe.Replace('_', '+').Replace('-', '/'));

            // Verifico che non sia passata più di 1 ora dalla richiesta di Unsubscribe
            bool decryptOk = _commonServices.DecryptNonce(keyUnsubscribe, out parametri);

            if (!decryptOk)
            {
                _orchardServices.Notifier.Error(T("Unsubscribe impossible. Please try again."));
                return(false);
            }

            string[] infoKey  = parametri.Split('&');
            string[] parEmail = infoKey[0].Split('=');
            string   email    = parEmail[1];

            // Verifico tra i contatti che sia presente la mail e la key (nonce)
            List <CommunicationEmailRecord> listaCommunicationEmail = (from m in _emailrepository.Table
                                                                       where m.Email.Equals(email) && m.KeyUnsubscribe.Equals(keyUnsubscribe)
                                                                       select m).ToList();

            if (listaCommunicationEmail == null)
            {
                _orchardServices.Notifier.Error(T("Email not found!"));
                return(false);
            }

            // Update CommunicationEmailRecord - Delete Nonce, Save DataUnsubscribe, set AccettatoUsoCommerciale false
            foreach (CommunicationEmailRecord recordMail in listaCommunicationEmail)
            {
                recordMail.KeyUnsubscribe          = null;
                recordMail.DataUnsubscribe         = DateTime.Now;
                recordMail.AccettatoUsoCommerciale = false;

                _emailrepository.Update(recordMail);
            }

            return(true);
        }
Exemple #3
0
        public PaymentRecord DecryptPaymentNonce(string nonce)
        {
            PaymentRecord record    = null;
            string        parametri = null;

            if (_commonsServices.DecryptNonce(Uri.UnescapeDataString(nonce), out parametri))
            {
                record = new PaymentRecord();
                var aux = parametri.Split('&');
                foreach (var par in aux)
                {
                    var kv = par.Split('=');
                    if (kv.Length == 2)
                    {
                        switch (kv[0])
                        {
                        case "reason":
                            record.Reason = Uri.UnescapeDataString(kv[1]);
                            break;

                        case "amount":
                            record.Amount = Convert.ToDecimal(Uri.UnescapeDataString(kv[1]), CultureInfo.InvariantCulture);
                            break;

                        case "currency":
                            record.Currency = Uri.UnescapeDataString(kv[1]);
                            break;

                        case "itemId":
                            record.ContentItemId = Convert.ToInt32(Uri.UnescapeDataString(kv[1]), CultureInfo.InvariantCulture);
                            break;
                        }
                    }
                }
            }
            return(record);
        }