Exemplo n.º 1
0
        public void RequestActivation(string fullName, string emailAddress)
        {
            string activationKey = "";

            using (var db = new SubscriptionContext())
            {
                activationKey = db.ActivationCodes.FirstOrDefault().CodeName;
            }
            SendActivationCodeEmail(emailAddress, fullName, activationKey);
        }
Exemplo n.º 2
0
        public ClientInfo AddSubscription(string fullName, string emailAddress, string macAddress, string activationCode)
        {
            ClientInfo clientInfo = new ClientInfo();

            using (var db = new SubscriptionContext())
            {
                var checkForKey = db.ActivationCodes.Where(c => c.CodeName == activationCode).FirstOrDefault();
                if (checkForKey != null)
                {
                    bool isActivatedAlready = false;

                    isActivatedAlready = db.UserSubscriptions.Where(t => t.FullName == fullName && t.EmailAddress == emailAddress).Count() > 0;

                    if (!isActivatedAlready)
                    {
                        var usrSub = new CleanerService.UserSubscription();
                        usrSub.FullName           = fullName;
                        usrSub.EmailAddress       = emailAddress;
                        usrSub.MacAddress         = macAddress;
                        usrSub.ActivationCode     = activationCode;
                        usrSub.IsEnabled          = true;
                        clientInfo.ActivationCode = activationCode;

                        usrSub.CreatedOn  = DateTime.Now;
                        usrSub.ModifiedOn = DateTime.Now;

                        db.UserSubscriptions.Add(usrSub);
                        db.SaveChanges();
                    }
                    else
                    {
                        clientInfo.ErrorCode = 2;
                    }
                }
                else
                {
                    clientInfo.ErrorCode = 1;
                }
            }

            clientInfo.FullName     = fullName;
            clientInfo.EmailAddress = emailAddress;
            clientInfo.MacId        = macAddress;
            return(clientInfo);
        }
Exemplo n.º 3
0
        public bool IsValidSubscription(string fullName, string emailAddress, string macAddress, string activationCode)
        {
            bool isValid = false;

            using (var db = new SubscriptionContext())
            {
                if (db.UserSubscriptions.Where(t =>
                                               t.EmailAddress == emailAddress &&
                                               t.MacAddress == macAddress &&
                                               t.ActivationCode == activationCode &&
                                               t.IsEnabled == true
                                               ).Count() > 0)
                {
                    isValid = true;
                }
            }
            return(isValid);
        }
Exemplo n.º 4
0
        public ClientInfo GetSubscriptionInfo(string fullName, string emailAddress, string macAddress)
        {
            ClientInfo clientInfo = new ClientInfo();

            using (var db = new SubscriptionContext())
            {
                var subscription = db.UserSubscriptions.Where(u => u.FullName.ToLower() == fullName.ToLower() &&
                                                              u.EmailAddress.ToLower() == emailAddress &&
                                                              u.MacAddress == macAddress &&
                                                              u.IsEnabled == true).FirstOrDefault();

                if (subscription != null)
                {
                    clientInfo.FullName     = subscription.FullName;
                    clientInfo.EmailAddress = subscription.EmailAddress;
                    clientInfo.IsEnabled    = subscription.IsEnabled.Equals(true) ? 1 : 0;
                }
                else
                {
                    clientInfo.ActivationCode = db.ActivationCodes.FirstOrDefault().CodeName;
                }
            }
            return(clientInfo);
        }