예제 #1
0
        public void SaveSettings(UserEntry userEntry)
        {
            UserEntry dbEntry = userContext.UserSettingsTable.Find(userEntry.Id);
            if (dbEntry != null)
            {
                userContext.Entry(dbEntry).CurrentValues.SetValues(userEntry);
            }

            userContext.SaveChanges();

        }
예제 #2
0
        private FitbitUser CreateFitbitUser(UserEntry userEntry)
        {
            AFElement userElement = _afAccess.GetElementFromName(userEntry.UserName);

            if (userElement == null) return null;

            return _fitbitUserFactory.CreateFitbitUser(ConfigurationManager.AppSettings["fitbitConsumerKey"],
                                                       ConfigurationManager.AppSettings["fitbitConsumerSecret"],
                                                       userEntry.FitbitAuthToken,
                                                       userEntry.FitbitAuthTokenSecret,
                                                       userElement,
                                                       true);
        }
예제 #3
0
        private void TryAddFitbitUserToCache(UserEntry userEntry)
        {
            string userName = userEntry.UserName;

            FitbitUser fitbitUser = null;
            _fitbitUserCache.TryGetValue(userName, out fitbitUser);

            if (fitbitUser == null)
            {
                fitbitUser = CreateFitbitUser(userEntry);
                
                if (fitbitUser == null)
                {
                    PIFitnessLog.Write(TraceEventType.Information, 0, string.Format("Unable to create FitbitUser for {0}", userName));
                }

                _fitbitUserCache[userName] = fitbitUser;
                PIFitnessLog.Write(TraceEventType.Information, 0, string.Format("Added {0} to FitbitClient cache", userName));
            }

        }