Пример #1
0
        private string GetGoogleCloudMessagingNotificationKey(string userName)
        {
            User user = new ReminderContext()
                .Users
                .Where(u => u.Username == userName)
                .SingleOrDefault();

            if (user == null)
            {
                throw new Exception("No user found matching {0} when attempting to push a Google Cloud Messaging update");
            }

            return user.NotificationKey;
        }
Пример #2
0
        internal string GetUsersAccessToken(string username)
        {
            var context = new ReminderContext();

            User user = context.Users.Where(r => r.Username == username).SingleOrDefault();

            if (user == null)
            {
                Logger.Log(null, string.Format("Unable to find user {0} when attempting to disconnect them.", username));
                return null;
            }

            if(string.IsNullOrEmpty(user.AccessToken))
            {
                Logger.Log(null, string.Format("The user {0} doesn't have an access token.", user));
                return null;
            }

            return user.AccessToken;
        }
        public IEnumerable<Reminder> PostSyncReminders(int[] reminderIdsToDisable)
        {
            var context = new ReminderContext();

            IEnumerable<Reminder> remindersToDisable = context.Reminders.Where(
                r =>
                    r.User.Username == User.Identity.Name &&
                    reminderIdsToDisable.Contains(r.Id));

            remindersToDisable.ToList().ForEach(
                r => r.Enabled = false);

            context.SaveChanges();

            var reminders = context.Reminders.Where(
                r =>
                    r.User.Username == User.Identity.Name &&
                    r.Enabled)
                        .ToList();

            return reminders;
        }
Пример #4
0
 static Logger()
 {
     context = new ReminderContext();
 }
Пример #5
0
 public UserCreator()
 {
     this.apiService = new GoogleApiService();
     this.context = new ReminderContext();
 }