コード例 #1
0
ファイル: InMemoryStorage.cs プロジェクト: Rayvor/MaxTests
        public List <ReminderItem> Get(ReminderStatus status, int count = 0, int startPosition = 0)
        {
            var items = reminders.Values.ToList().Where(r => r._status == status).ToList();

            if (startPosition != 0)
            {
                items = items.Skip(startPosition).ToList();
            }
            return(items = count != 0 ? items.Take(count).ToList() : items);
        }
コード例 #2
0
ファイル: InMemoryStorage.cs プロジェクト: Rayvor/MaxTests
 public void UpdateStatus(IEnumerable <Guid> ids, ReminderStatus status)
 {
     foreach (Guid id in ids)
     {
         if (reminders.ContainsKey(id))
         {
             reminders[id]._status = status;
         }
     }
 }
コード例 #3
0
 public void ConfirmReceipt(int reminderId)
 {
     using (var db = new AppContext())
     {
         var reminder = db.Reminders.Where(x => x.Id == reminderId).SingleOrDefault();
         if (reminder != null)
         {
             reminder.Status = ReminderStatus.Received();
             db.Entry(reminder).Property(x => x.Status).IsModified = true;
             db.SaveChanges();
         }
     }
 }
コード例 #4
0
ファイル: InMemoryStorage.cs プロジェクト: Rayvor/MaxTests
 public void UpdateStatus(Guid id, ReminderStatus status)
 {
     reminders[id]._status = status;
 }
コード例 #5
0
 public async Task <IEnumerable <ReminderEntity> > GetRemindersByUserIdAsync(string userId, ReminderStatus status = ReminderStatus.Active)
 {
     using (MySqlConnection conn = new MySqlConnection(connectionStringFactory.GetConnectionString()))
     {
         return(await conn.QueryAsync <ReminderEntity>("SELECT ID, UserID, Title, Description, ForDate, Created, Recurrence, Importance, LastActioned FROM reminders WHERE UserID = @userId AND Status = @status;",
                                                       new
         {
             userId,
             status = (int)status
         }));
     }
 }
コード例 #6
0
        public async Task <bool> SetReminderStatusAsync(string userId, long reminderId, ReminderStatus status)
        {
            using (MySqlConnection conn = new MySqlConnection(connectionStringFactory.GetConnectionString()))
            {
                var updated = await conn.ExecuteAsync(
                    @"UPDATE reminders SET Status = @status WHERE ID = @id AND UserID = @userId;",
                    new
                {
                    id = reminderId,
                    userId,
                    status = (int)status,
                });

                return(updated > 0);
            }
        }
コード例 #7
0
 public async Task <bool> SetReminderStatusAsync(string userId, long reminderId, ReminderStatus status)
 {
     return(await this.remindersRepository.SetReminderStatusAsync(userId, reminderId, status));
 }
コード例 #8
0
        public async Task <IEnumerable <Reminder> > GetRemindersByUserIdAsync(string userId, ReminderStatus status)
        {
            var reminders = (await this.remindersRepository.GetRemindersByUserIdAsync(userId, status)).ToList();

            return(reminders.Select(MapReminder).ToList());
        }
コード例 #9
0
 public Task <bool> SetReminderStatusAsync(string userId, long reminderId, ReminderStatus status)
 {
     return(Task.FromResult(true));
 }
コード例 #10
0
 public Task <IEnumerable <ReminderEntity> > GetRemindersByUserIdAsync(string userId, ReminderStatus status)
 {
     return(Task.FromResult(new List <ReminderEntity>
     {
         new ReminderEntity
         {
             Recurrence = Recurrence.Annual,
             ForDate = DateTime.UtcNow,
             LastActioned = null,
             Description = "Annual reminder 1",
             Importance = Importance.Important,
             Title = "Annual 1",
             Created = DateTime.UtcNow,
             Id = 1
         },
         new ReminderEntity
         {
             Recurrence = Recurrence.Annual,
             ForDate = DateTime.UtcNow,
             LastActioned = null,
             Description = "Annual reminder 2",
             Importance = Importance.Important,
             Title = "Annual 2",
             Created = DateTime.UtcNow,
             Id = 2
         },
         new ReminderEntity
         {
             Recurrence = Recurrence.Annual,
             ForDate = DateTime.UtcNow,
             LastActioned = null,
             Description = "Annual reminder 3",
             Importance = Importance.Important,
             Title = "Annual 3",
             Created = DateTime.UtcNow,
             Id = 3
         }
     } as IEnumerable <ReminderEntity>));
 }