public void AddEvaluationSubscription(string name, string email, string companyname)
        {
            if (_userDao.ReadByEmail(email) == null)
            {
                var subscription = new Subscription
                {
                    SubscriptionReference = $"{email}_{DateTime.Now.ToLongDateString()}",
                    Status         = SubscriptionStatus.Active,
                    StatusChanged  = DateTime.Today,
                    Cancelable     = true,
                    SourceName     = "PINZonline.com",
                    SourceCampaign = "Trial",
                    Test           = true,
                    Quantity       = 1,
                    End            = DateTime.Today.AddMonths(1),
                    Customer       = new Customer
                    {
                        LastName = name,
                        Email    = email,
                        Company  = companyname
                    }
                };

                UserDO user = _subscriptionUtils.CreateSubscription(subscription, email);
                InvitationEmailSender.SendTrialInvitation(user.EMail, user.Password);
                _log.InfoFormat("Trial subsciption ID:{0}, email sent. Activation finished successfully.",
                                subscription.SubscriptionReference);
            }
        }
Beispiel #2
0
        public UserDO InviteNewUser(string newUserEmail, Guid projectId, Guid invitingUserId)
        {
            var project      = _projectDao.GetById(projectId);
            var invitingUser = _userDao.GetById(invitingUserId);

            var generatedPassword = RandomPassword.Generate();
            var user = new UserDO
            {
                EMail            = newUserEmail,
                IsCompanyAdmin   = false,
                IsPinzSuperAdmin = false,
                CompanyId        = invitingUser.CompanyId,
                Password         = generatedPassword
            };

            user = _userDao.Create(user);
            AddUserToProject(user.UserId, projectId, false);

            InvitationEmailSender.SendProjectInvitation(newUserEmail, invitingUser, project, generatedPassword);

            return(user);
        }
Beispiel #3
0
        public void Activate(FastSpringNotificationParameter parameter)
        {
            var subscription = RetrieveSubscription(parameter.SubscriptionReference);

            _log.InfoFormat("Subscription {0} ACTIVATE request recieved.", subscription);

            if (subscription.ProductName.StartsWith("Basic"))
            {
                subscription.Quantity = 1;
            }
            else if (subscription.ProductName.StartsWith("Standard"))
            {
                subscription.Quantity = 5;
            }
            else if (subscription.ProductName.StartsWith("Large"))
            {
                subscription.Quantity = 15;
            }

            var user = _userDao.ReadByEmail(subscription.Customer.Email);

            if (user == null)
            {
                var newUser = _subscriptionUtils.CreateSubscription(subscription, subscription.Customer.Email);

                //send EMail
                InvitationEmailSender.SendNewCustomerInvitation(newUser.EMail, newUser.Password);
                _log.InfoFormat("Subscription ID:{0}, email sent. Activation finished successfully.",
                                subscription.SubscriptionReference);
            }
            else
            {
                var subscriptionDo = _companyDao.ReadSubscriptionByCompanyId(user.CompanyId);
                if (user.IsCompanyAdmin &&
                    (subscriptionDo.Test || (subscriptionDo.Status == SubscriptionStatus.Inactive)))
                {
                    var newSubscriptionDo = _mapper.Map <SubscriptionDO>(subscription);
                    _log.InfoFormat("Subscription ID:{0}, subscription created in DB. {1}",
                                    subscription.SubscriptionReference,
                                    subscriptionDo);
                    var company = _companyDao.ReadCompanyById(user.CompanyId);
                    company.SubscriptionReference = newSubscriptionDo.SubscriptionReference;
                    company.Subscription          = newSubscriptionDo;
                    _companyDao.Update(company);
                    _log.InfoFormat("Subscription ID:{0}, company updated in DB. {1}",
                                    subscription.SubscriptionReference,
                                    company);

                    _subscriptionDao.Delete(subscriptionDo);

                    if (subscriptionDo.Test)
                    {
                        InvitationEmailSender.SendTrialToSubscription(user.EMail, user.Password);
                    }
                    else if (subscriptionDo.Status == SubscriptionStatus.Inactive)
                    {
                        InvitationEmailSender.WellcomeBack(user.EMail);
                    }
                    _log.InfoFormat("Subscription ID:{0}, email sent. Activation finished successfully.",
                                    newSubscriptionDo.SubscriptionReference);
                }
                else
                {
                    var originalEmail = subscription.Customer.Email;
                    subscription.Customer.Email = FindNewCustomerLoginEmail(originalEmail);
                    var newUser = _subscriptionUtils.CreateSubscription(subscription, originalEmail);

                    //send EMail
                    InvitationEmailSender.SendNewCustomerDuplicateInvitation(originalEmail, newUser.EMail,
                                                                             newUser.Password);
                    _log.InfoFormat("Subscription ID:{0}, email sent. Activation finished successfully.",
                                    subscription.SubscriptionReference);
                }
            }
        }
Beispiel #4
0
        public void Deactivated(FastSpringNotificationParameter parameter)
        {
            var subscription = UpdateSubscriptionInDb(parameter.SubscriptionReference, "DEACTIVATED");

            InvitationEmailSender.SendGoodbye(subscription.Customer.Email);
        }