Beispiel #1
0
        public virtual void InsertSubscription(Subscription subscription)
        {
            if (subscription == null)
                throw new ArgumentNullException("Subscription");

            //Handle e-mail
            subscription.Email = CommonHelper.EnsureSubscriberEmail(subscription.Email);

            //Persist
            _subscriptionRepository.Insert(subscription);
        }
Beispiel #2
0
        public virtual void UpdateSubscription(Subscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("Subscription");
            }

            //Handle e-mail
            subscription.Email = CommonHelper.EnsureSubscriberEmail(subscription.Email);
            _subscriptionRepository.Update(subscription);
        }
Beispiel #3
0
        public virtual void DeleteSubscription(Subscription subscription)
        {
            if (subscription == null) throw new ArgumentNullException("Subscription");

            _subscriptionRepository.Delete(subscription);
        }
Beispiel #4
0
        public ActionResult Subscribe(string email)
        {
            string result;
            bool success = false;

            if (!CommonHelper.IsValidEmail(email))
                result = "Wrong Email";
            else
            {
                //subscribe/unsubscribe
                email = email.Trim();

                var subscription = _subscribeService.GetSubscriptionByEmail(email);
                if (subscription != null)
                {
                    result = "Thank you for signing up! We appreciate your interest.";
                }
                else
                {
                    subscription = new Subscription()
                    {
                        SubscriptionGuid = Guid.NewGuid(),
                        Email = email,
                        Active = true,
                        CreatedOnUtc = DateTime.UtcNow
                    };
                    _subscribeService.InsertSubscription(subscription);
                    result = "Thank you for signing up! We appreciate your interest.";
                }
                success = true;
            }

            return Json(new
            {
                Success = success,
                Result = result,
            });
        }