Beispiel #1
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, IHeroTaskListDbContext dbContext,
                       IDbContextSeeder contextSeeder)
 {
     app.UseGraphiQl("/graphql");
     app.UseWebSockets();
     app.UseGraphQLWebSockets <HeroTaskListSchema>("/graphql");
     app.UseGraphQL <HeroTaskListSchema>();
     dbContext.Migrate();
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
     contextSeeder.Seed(dbContext);
 }
 public AssignmentStatusRepository(IHeroTaskListDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Beispiel #3
0
 public void Seed(IHeroTaskListDbContext context)
 {
     if (!context.Categories.Any())
     {
         context.Categories.Add(
             new Category
         {
             Description = "ToRead"
         });
         context.Categories.Add(
             new Category
         {
             Description = "MoviesToWatch"
         });
         context.Categories.Add(
             new Category
         {
             Description = "Projects To Do"
         });
         context.Categories.Add(
             new Category
         {
             Description = "To Learn"
         });
         context.SaveChanges();
     }
     ;
     if (!context.Assignments.Any())
     {
         context.Assignments.Add(
             new Assignment
         {
             Name        = "Read ProC#",
             Description = "Finish reading remaining chapters",
             DueDate     = new DateTime(2019, 03, 15),
             CategoryId  = 1,
             Important   = true,
             Status      = new AssignmentStatus
             {
                 Status = StatusEnum.Started.ToString()
             }
         });
         context.Assignments.Add(
             new Assignment
         {
             Name        = "Watch Star Wars",
             Description = "Watch all parts",
             DueDate     = new DateTime(2019, 05, 31),
             CategoryId  = 2,
             Important   = false,
             Status      = new AssignmentStatus
             {
                 Status = StatusEnum.Done.ToString()
             }
         });
         context.Assignments.Add(
             new Assignment
         {
             Name        = "Finish GraphQL project",
             Description = "Finish project",
             DueDate     = new DateTime(2019, 02, 28),
             CategoryId  = 3,
             Important   = true,
             Status      = new AssignmentStatus
             {
                 Status = StatusEnum.NotDone.ToString()
             }
         });
         context.Assignments.Add(
             new Assignment
         {
             Name        = "Learn Angular",
             Description = "Should be able to make front for a new app",
             DueDate     = new DateTime(2019, 02, 15),
             CategoryId  = 4,
             Important   = true,
             Status      = new AssignmentStatus
             {
                 Status = StatusEnum.Outdated.ToString()
             }
         });
         context.SaveChanges();
     }
     ;
     if (!context.SubTasks.Any())
     {
         context.SubTasks.Add(
             new SubTask
         {
             Name        = "A Phantom Menace",
             Description = "Watch First Episode",
             TaskId      = 2
         });
         context.SaveChanges();
     }
     ;
 }
 public SubTask ToEntity(IHeroTaskListDbContext context)
 {
     Task = context.Assignments.FirstOrDefault(x => x.Id == TaskId);
     return(this);
 }
Beispiel #5
0
 public SubTaskRepository(IHeroTaskListDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public CategoryRepository(IHeroTaskListDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public Assignment ToEntity(IHeroTaskListDbContext dbContext)
 {
     Category = dbContext.Categories.SingleOrDefault(x => x.Id == CategoryId);
     Status   = dbContext.Statuses.SingleOrDefault(x => x.Id == StatusId);
     return(this);
 }