public ActionResult Index(int id = 1) { using (var context = new TempRepoContext()) { var vm = new CharacterViewModel(); vm.Character = context.Characters.FirstOrDefault(x => x.CharacterId == id); // Get parents vm.RelatedCharacters = context.CharacterRelationship .Where(x => x.ParentCharacter.CharacterId == id) .Select(x => new Character() { CharacterId = x.ChildCharacter.CharacterId, Name = x.ChildCharacter.Name }).ToList(); // Get children vm.RelatedCharacters.AddRange(context.CharacterRelationship .Where(x => x.ChildCharacter.CharacterId == id) .Select(x => new Character() { CharacterId = x.ParentCharacter.CharacterId, Name = x.ParentCharacter.Name }).ToList()); // strip duplicates vm.RelatedCharacters = vm.RelatedCharacters.Distinct(new DistinctCharacterComparer()).ToList(); return(View(vm)); } }
public ActionResult Create() { using (var context = new TempRepoContext()) { var vm = new CharacterRelationshipsViewModel(); vm.Characters = context.Characters.AsNoTracking().OrderBy(c => c.Name).ToList(); vm.Relationships = context.Relationships.AsNoTracking().OrderBy(r => r.Description).ToList(); return(View(vm)); } }
public ActionResult Create(CharacterRelationshipsViewModel viewModel) { using (var context = new TempRepoContext()) { context.CharacterRelationship.Add(new CharacterRelationships() { ChildCharacter = context.Characters.SingleOrDefault(x => x.CharacterId == viewModel.SelectedChildCharacter), ParentCharacter = context.Characters.SingleOrDefault(x => x.CharacterId == viewModel.SelectedParentCharacter), Relationship = context.Relationships.SingleOrDefault(x => x.RelationshipId == viewModel.SelectedRelationship), }); context.SaveChanges(); } return(RedirectToAction("Index", viewModel)); }
public async Task <IActionResult> Index() { using (var context = new TempRepoContext()) { var model = await context.CharacterRelationship .Include(CharacterRelationships => CharacterRelationships.ParentCharacter) .Include(CharacterRelationships => CharacterRelationships.ChildCharacter) .Include(CharacterRelationships => CharacterRelationships.Relationship) .AsNoTracking() .ToListAsync(); return(View(model)); } }
public async Task SyncCommit() { var credentials = CredentialsHelper.Credentials; var repoSync = new RepoSync(WriteLine); await using var repoContext = await TempRepoContext.Create(Context.MethodName, this); repoSync.AddSourceRepository(new RepositoryInfo(credentials, "SimonCropp", "GitHubSync.TestRepository", "source")); repoSync.RemoveBlob("README.md"); repoSync.AddTargetRepository(new RepositoryInfo(credentials, "SimonCropp", "GitHubSync.TestRepository", repoContext.TempBranchName)); var sync = await repoSync.Sync(SyncOutput.CreateCommit); await repoContext.VerifyCommit(sync.Single()); }
public async Task SyncPrExcludeAllByDefault() { var credentials = CredentialsHelper.Credentials; var repoSync = new RepoSync(WriteLine, syncMode: SyncMode.ExcludeAllByDefault); await using var repoContext = await TempRepoContext.Create(Context.MethodName, this); repoSync.AddSourceRepository(new RepositoryInfo(credentials, "SimonCropp", "GitHubSync.TestRepository", "source")); repoSync.AddBlob("sourceFile.txt"); repoSync.AddSourceItem(TreeEntryTargetType.Blob, "sourceFile.txt", "nested/sourceFile.txt"); repoSync.AddTargetRepository(new RepositoryInfo(credentials, "SimonCropp", "GitHubSync.TestRepository", repoContext.TempBranchName)); var sync = await repoSync.Sync(); await repoContext.VerifyPullRequest(sync.Single()); }