public void ResendCode(string deviceId, string emailAddress)
        {
            IRepository repo = new RepositoryInitiator().FactoryMethod();
            var         user = repo.All <TrackUsers>().Where(i => i.DeviceId == deviceId).First();

            user.Email = emailAddress;
            repo.Update(user);
            EmailManager.GetInstance().SendEmail(user.Name, user.Email, user.ActivationCode);
        }
 public bool UpdateIsActivated(string deviceId, string activationCode)
 {
     try
     {
         IRepository repo   = new RepositoryInitiator().FactoryMethod();
         var         result = repo.All <TrackUsers>().Where(i => i.DeviceId == deviceId && i.ActivationCode == activationCode).First();
         if (result != null)
         {
             result.IsActivated = true;
             repo.Update <TrackUsers>(result);
             EmailManager.GetInstance().SendCompletionEmail(result.Name, result.Email);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception) { return(false); }
 }
 public long RegisterUser(string deviceId, string activationCode, string name, string emailAddress)
 {
     try
     {
         IRepository repo   = new RepositoryInitiator().FactoryMethod();
         Random      random = new Random();
         activationCode = random.Next(1000, 9999).ToString();
         var result = repo.Create <TrackUsers>(new TrackUsers {
             DeviceId = deviceId, ActivationCode = activationCode, Email = emailAddress, Name = name
         });
         if (result != null)
         {
             EmailManager.GetInstance().SendEmail(name, emailAddress, activationCode);
             return(result.Id);
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception) { return(-2); }
 }