Example #1
0
 protected Repository(SchedulerDbContext context)
 {
     _context = context;
     _dbSet   = context.Set <TEntity>();
 }
Example #2
0
        public void Init()
        {
            TaskSettings.MinutesBetweenTasks = 5;
            var options = new DbContextOptionsBuilder <SchedulerDbContext>()
                          .UseInMemoryDatabase("Scheduler")
                          .Options;

            _context = new SchedulerDbContext(options);
            _context.RemoveRange(_context.Set <TaskEntity>());
            _context.SaveChanges();


            _taskRepository = new TaskRepository(_context);

            _taskRepository.Add(new TaskEntity()
            {
                Id        = -1,
                Comment   = "Comment",
                Created   = DateTime.Now,
                Direction = TaskDirection.Pvh,
                LoaderId  = 1,
                Type      = TaskType.Plan,
                PlanStart = new DateTime(2020, 01, 01, 5, 0, 0),
                PlanEnd   = new DateTime(2020, 01, 01, 6, 0, 0)
            });

            _taskRepository.Add(new TaskEntity()
            {
                Id        = -2,
                Comment   = "Comment",
                Created   = DateTime.Now,
                Direction = TaskDirection.Pvh,
                LoaderId  = 1,
                Type      = TaskType.Plan,
                PlanStart = new DateTime(2020, 01, 01, 7, 0, 0),
                PlanEnd   = new DateTime(2020, 01, 01, 8, 0, 0)
            });

            _taskRepository.Add(new TaskEntity()
            {
                Id        = -3,
                Comment   = "Comment",
                Created   = DateTime.Now,
                Direction = TaskDirection.Pvh,
                LoaderId  = 1,
                Type      = TaskType.Plan,
                PlanStart = new DateTime(2020, 01, 01, 9, 0, 0),
                PlanEnd   = new DateTime(2020, 01, 01, 10, 0, 0)
            });

            _taskRepository.Add(new TaskEntity()
            {
                Id        = -4,
                Comment   = "Comment",
                Created   = DateTime.Now,
                Direction = TaskDirection.Pvh,
                LoaderId  = 1,
                Type      = TaskType.Plan,
                PlanStart = new DateTime(2020, 01, 01, 11, 0, 0),
                PlanEnd   = new DateTime(2020, 01, 01, 12, 0, 0)
            });

            _taskRepository.Add(new TaskEntity()
            {
                Id        = -5,
                Comment   = "Comment",
                Created   = DateTime.Now,
                Direction = TaskDirection.Pvh,
                LoaderId  = 1,
                Type      = TaskType.Plan,
                PlanStart = new DateTime(2020, 01, 01, 16, 0, 0),
                PlanEnd   = new DateTime(2020, 01, 01, 17, 0, 0)
            });

            _taskRepository.SaveChanges();
        }
Example #3
0
 public async Task Add(T entity)
 {
     context.Set <T>().Add(entity);
     await context.SaveChangesAsync();
 }