public List <ReminderItem> Get(int count = 0, int startPostion = 0)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         if (count == 0 && startPostion == 0)
         {
             return(context.ReminderItems
                    .Select(r => r.ToReminderItem())
                    .ToList());
         }
         if (count == 0)
         {
             return(context.ReminderItems
                    .OrderBy(r => r.Id)
                    .Skip(startPostion)
                    .Select(r => r.ToReminderItem())
                    .ToList());
         }
         return(context.ReminderItems
                .OrderBy(r => r.Id)
                .Skip(startPostion)
                .Take(count)
                .Select(r => r.ToReminderItem())
                .ToList());
     }
 }
Пример #2
0
 public ReminderItem Get(Guid id)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         return(context.ReminderItems.FirstOrDefault(ri => ri.Id == id)?.ToReminderItem());
     }
 }
Пример #3
0
        public List <ReminderItem> Get(ReminderItemStatus status, int count, int startPostion)
        {
            using (var context = new ReminderStorageContext(_builder.Options))
            {
                if (count == 0 && startPostion == 0)
                {
                    return(context.ReminderItem
                           .Where(ri => ri.Status.Equals(status))
                           .Select(r => r.ToReminderItem())
                           .ToList());
                }

                if (count == 0 && startPostion != 0)
                {
                    return(context.ReminderItem
                           .Where(ri => ri.Status.Equals(status))
                           .OrderBy(r => r.Id)
                           .Skip(startPostion)
                           .Select(r => r.ToReminderItem())
                           .ToList());
                }

                return(context.ReminderItem
                       .Where(ri => ri.Status.Equals(status))
                       .OrderBy(r => r.Id)
                       .Skip(startPostion)
                       .Take(count)
                       .Select(r => r.ToReminderItem())
                       .ToList());
            }
        }
 public void UpdateStatus(Guid id, ReminderItemStatus status)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         ReminderItemDto dto = context.ReminderItems.Find(id);
         dto.Status = status;
         context.SaveChanges();
     }
 }
Пример #5
0
 public void UpdateStatus(Guid id, ReminderItemStatus status)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         var reminderItem = context.ReminderItem.FirstOrDefault(ri => ri.Id.Equals(id));
         reminderItem.Status = status;
         context.SaveChanges();
     }
 }
Пример #6
0
 public List <ReminderItem> Get(ReminderItemStatus status)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         return(context.ReminderItems.Where(ri => ri.Status == status)
                .Select(r => r.ToReminderItem())
                .ToList());
     }
 }
        public Guid Add(ReminderItemRestricted reminder)
        {
            var dto = new ReminderItemDto();

            using (var context = new ReminderStorageContext(_builder.Options))
            {
                context.ReminderItems.Add(dto);
                context.SaveChanges();
                return(dto.Id);
            }
        }
Пример #8
0
 public void UpdateStatus(IEnumerable <Guid> ids, ReminderItemStatus status)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         var reminderItems = context.ReminderItem.Where(ri => ids.Contains(ri.Id)).ToList();
         foreach (var dto in reminderItems)
         {
             dto.Status = status;
         }
         context.SaveChanges();
     }
 }
Пример #9
0
        public List <ReminderItem> Get(ReminderItemStatus status)
        {
            using (var context = new ReminderStorageContext(_builder.Options))
            {
                var dtos = context.ReminderItem
                           .Where(ri => ri.Status.Equals(status))
                           .Select(ri => ri.ToReminderItem())
                           .ToList();

                return(dtos);
            }
        }
Пример #10
0
        public void UpdateStatus(Guid id, ReminderItemStatus status)
        {
            using (var context = new ReminderStorageContext(_builder.Options))
            {
                var reminder = context.ReminderItems.FirstOrDefault(r => r.Id == id);

                if (reminder != null)
                {
                    reminder.Status = status;
                    context.SaveChanges();
                }
            }
        }
Пример #11
0
        public void UpdateStatus(IEnumerable <Guid> ids, ReminderItemStatus status)
        {
            using (var context = new ReminderStorageContext(_builder.Options))
            {
                var reminders = context.ReminderItems.Where(r => ids.Contains(r.Id)).ToList().Select(r => { r.Status = status; return(r); }).ToList();

                //foreach (var reminder in reminders)
                //{
                //    reminder.Status = status;
                //}
                context.SaveChanges();
            }
        }
Пример #12
0
        public List <ReminderItem> Get(ReminderItemStatus status)
        {
            var reminders = new List <ReminderItem>();

            using (var context = new ReminderStorageContext(_builder.Options))
            {
                reminders = context.ReminderItems
                            .Where(r => r.Status == status)
                            .Select(r => r.ToReminderItem())
                            .ToList();
            }
            return(reminders);
        }
Пример #13
0
 public bool Remove(Guid id)
 {
     using (var context = new ReminderStorageContext(_builder.Options))
     {
         var reminder = context.ReminderItem.FirstOrDefault(ri => ri.Id.Equals(id));
         if (reminder == null)
         {
             return(false);
         }
         context.ReminderItem.Remove(reminder);
         context.SaveChanges();
         return(true);
     }
 }
        public bool Remove(Guid id)
        {
            using (var context = new ReminderStorageContext(_builder.Options))
            {
                var dto = context.ReminderItems.FirstOrDefault(r => r.Id == id);
                if (dto == null)
                {
                    return(false);
                }

                context.ReminderItems.Remove(dto);
                context.SaveChanges();
                return(true);
            }
        }
Пример #15
0
        public Guid Add(ReminderItemRestricted reminder)
        {
            var reminderDto = new ReminderItemDto
            {
                ContactId  = reminder.ContactId,
                TargetDate = reminder.Date,
                Message    = reminder.Message,
                Status     = reminder.Status
            };

            using (var context = new ReminderStorageContext(_builder.Options))
            {
                context.ReminderItems.Add(reminderDto);
                context.SaveChanges();
                return(reminderDto.Id);
            }
        }
 public MigrationHostedService(ReminderStorageContext context)
 {
     _context = context;
 }