public IndexModel(UserManager <IdentityResource> userManager, SignInManager <IdentityResource> signInManager, IQualificationService <IdentityResource> qualificationService, PMAppDbContext context) { _userManager = userManager; _signInManager = signInManager; _qualificationService = qualificationService; _context = context; }
public async Task GetAllAsyncTest() { await using var context = new PMAppDbContext(ContextOptions); ProjectRepository repository = new ProjectRepository(context); IEnumerable <Project> projects = await repository.GetAllAsync(); Assert.AreEqual(1, projects.Count()); }
public async Task GetOneAsyncTest() { await using var context = new PMAppDbContext(ContextOptions); ProjectRepository repository = new ProjectRepository(context); var project = await repository.GetOneAsync(1); Assert.AreEqual("Space Project", project.Name); }
public async Task DeleteAsyncTest() { await using var context = new PMAppDbContext(ContextOptions); ProjectRepository repository = new ProjectRepository(context); await repository.DeleteAsync(1); IEnumerable <Project> projects = await repository.GetAllAsync(); Assert.IsTrue(!projects.Any()); }
public async Task AddAsyncTest() { await using var context = new PMAppDbContext(ContextOptions); ProjectRepository repository = new ProjectRepository(context); var request = new Project { Name = "New project", FromDuration = new DateTime(2020, 5, 18), ToDuration = new DateTime(2021, 1, 15) }; var result = await repository.AddAsync(request); Assert.AreEqual(request.Name, result.Name); IEnumerable <Project> projects = await repository.GetAllAsync(); result = projects.FirstOrDefault(x => x.Name == request.Name); Assert.NotNull(result); Assert.AreEqual(request.Name, result.Name); }
public async Task UpdateAsyncTest() { await using var context = new PMAppDbContext(ContextOptions); ProjectRepository repository = new ProjectRepository(context); var updateRequest = new Project { Name = "ChangedName", Id = 1 }; var result = await repository.UpdateAsync(updateRequest); Assert.AreEqual(updateRequest.Name, result.Name); IEnumerable <Project> projects = await repository.GetAllAsync(); result = projects.FirstOrDefault(x => x.Name == updateRequest.Name); Assert.NotNull(result); Assert.AreEqual(updateRequest.Name, result.Name); }
public ProjectRepository(PMAppDbContext context) { _context = context; }
public IdentityResourceQualificationService(PMAppDbContext context) { _context = context; }
public QualificationRepository(PMAppDbContext context) { _context = context; }
public SkillRepository(PMAppDbContext context) { _context = context; }
public SummaryService(PMAppDbContext context) { _context = context; }
public ProjectQualificationService(PMAppDbContext context) { _context = context; }
public NotificationRepository(PMAppDbContext context, IHubContext <SignalServer> hubContext) { _context = context; _hubContext = hubContext; }
public ProjectResourceService(PMAppDbContext context) { _context = context; }
private async Task Seed() { await using var context = new PMAppDbContext(ContextOptions); await context.Database.EnsureDeletedAsync(); await context.Database.EnsureCreatedAsync(); // initializing resources var steveResource = new IdentityResource { UserName = "******", Email = "*****@*****.**" }; var bobResource = new IdentityResource { UserName = "******", Email = "*****@*****.**" }; var jhonResource = new IdentityResource { UserName = "******", Email = "*****@*****.**" }; var katrinResource = new IdentityResource { UserName = "******", Email = "*****@*****.**" }; await context.AddRangeAsync(steveResource, bobResource, jhonResource, katrinResource); // initializing skills var csharpSkill = new Skill { Name = "C#" }; var excelSkill = new Skill { Name = "Excel" }; var drivingSkill = new Skill { Name = "Driving licence" }; var managerSkill = new Skill { Name = "Project management" }; await context.Skills.AddRangeAsync(csharpSkill, excelSkill, drivingSkill, managerSkill); // initializing qualifications var csharpJunior = new Qualification { Level = SkillLevel.Junior, Skill = csharpSkill }; var excelJunior = new Qualification { Level = SkillLevel.Junior, Skill = excelSkill }; var drivingJunior = new Qualification { Level = SkillLevel.Junior, Skill = drivingSkill }; var managerJunior = new Qualification { Level = SkillLevel.Junior, Skill = managerSkill }; var csharpMiddle = new Qualification { Level = SkillLevel.Middle, Skill = csharpSkill }; var excelMiddle = new Qualification { Level = SkillLevel.Middle, Skill = excelSkill }; var drivingMiddle = new Qualification { Level = SkillLevel.Middle, Skill = drivingSkill }; var managerMiddle = new Qualification { Level = SkillLevel.Middle, Skill = managerSkill }; var csharpSenior = new Qualification { Level = SkillLevel.Senior, Skill = csharpSkill }; var excelSenior = new Qualification { Level = SkillLevel.Senior, Skill = excelSkill }; var drivingSenior = new Qualification { Level = SkillLevel.Senior, Skill = drivingSkill }; var managerSenior = new Qualification { Level = SkillLevel.Senior, Skill = managerSkill }; await context.Qualifications.AddRangeAsync(csharpJunior, excelJunior, drivingJunior, managerJunior, csharpMiddle, excelMiddle, drivingMiddle, managerMiddle, csharpSenior, excelSenior, drivingSenior, managerSenior); // initializing project Project spaceProject = new Project { Name = "Space Project", Manager = steveResource, FromDuration = new DateTime(2020, 2, 10), ToDuration = new DateTime(2020, 8, 5) }; var projectQualifications = InitProjectQualification(spaceProject, csharpJunior, drivingMiddle, managerJunior, excelMiddle); await context.Projects.AddAsync(spaceProject); await context.ProjectQualifications.AddRangeAsync(projectQualifications); var projectResources = InitProjectResource(spaceProject, steveResource, katrinResource); await context.ProjectIdentityResources.AddRangeAsync(projectResources); var steveQualificationResources = InitQualificationResources(steveResource, csharpJunior, drivingMiddle); var katrinQualificationResources = InitQualificationResources(katrinResource, drivingMiddle); var bobQualificationResources = InitQualificationResources(bobResource, excelMiddle); var jhonQualificationResources = InitQualificationResources(jhonResource, managerJunior, excelMiddle); await context.QualificationIdentityResources.AddRangeAsync(steveQualificationResources); await context.QualificationIdentityResources.AddRangeAsync(katrinQualificationResources); await context.QualificationIdentityResources.AddRangeAsync(bobQualificationResources); await context.QualificationIdentityResources.AddRangeAsync(jhonQualificationResources); await context.SaveChangesAsync(); }