private static async Task AddUsers(PicShareContext picShareContext) { var adminId = Guid.NewGuid(); var userId = Guid.NewGuid(); if (await picShareContext.Users.CountAsync() <= 0) { picShareContext.Users.Add(new User { Id = adminId, UserName = "******", PasswordHash = "$argon2id$v=19$m=65536,t=3,p=1$I0609UNaeXq9CLSaMlwCpA$ld9Qxs7hOHblGWJpH2SzapG9QsNrMhE6YhYpIZaw2jg" }); picShareContext.Users.Add(new User { Id = userId, UserName = "******", PasswordHash = "$argon2id$v=19$m=65536,t=3,p=1$I0609UNaeXq9CLSaMlwCpA$ld9Qxs7hOHblGWJpH2SzapG9QsNrMhE6YhYpIZaw2jg" }); await picShareContext.SaveChangesAsync(); } if (!await picShareContext.Pictures.AnyAsync()) { picShareContext.Pictures.Add(new Picture { Id = Guid.NewGuid(), UploaderId = adminId, }); await picShareContext.SaveChangesAsync(); } }
public static async Task <PicShareContext> GetDummyContext() { var options = new DbContextOptionsBuilder <PicShareContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var databaseContext = new PicShareContext(options); await databaseContext.Database.EnsureCreatedAsync(); await AddUsers(databaseContext); return(databaseContext); }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationService" /> class. /// </summary> /// <param name="database">The dabase service.</param> public AuthenticationService(PicShareContext database) { this.database = database; }
/// <summary> /// Initializes a new instance of the <see cref="PictureService" /> class. /// </summary> /// <param name="picShareContext">The picture context.</param> /// <param name="storageProvider">The storage provider.</param> public PictureService(PicShareContext picShareContext, IStorageProvider storageProvider) { this.picShareContext = picShareContext; this.storageProvider = storageProvider; }
public PicturesController(PicShareContext context, IHostingEnvironment environment) { _context = context; _env = environment; }
public HomeController(PicShareContext context) { _context = context; }