public ActionResult <Spel> Put([FromBody] Zet zet) { var result = _userContext.Spels.FirstOrDefault(item => item.Token == zet.SpelToken); if (result != null) { if (zet.SpelerToken == result.spelerWitToken) { result.SetTurn(zet); result.aanDeBeurt = 2; _userContext.SaveChanges(); } else if (zet.SpelerToken == result.spelerZwartToken) { result.SetTurn(zet); result.aanDeBeurt = 1; _userContext.SaveChanges(); } else { result.aanDeBeurt = 0; _userContext.SaveChanges(); } return(result); } else { return(new Spel { Token = "0", Omschrijving = "0", spelerWitToken = "0", spelerZwartToken = "0" }); } }
public async Task UpdateZet(Zet zetDieGeupdateMoetWorden, Zet zet) { zetDieGeupdateMoetWorden.BeginVeld = zet.BeginVeld; zetDieGeupdateMoetWorden.EindVeld = zet.EindVeld; zetDieGeupdateMoetWorden.PartijId = zet.PartijId; await _zetRepository.CommitAsync(); }
private static void TestPromotion() { bord.Load(Kleur.WIT, @" 8-. . . . . . . . ; 7 . . .+p . . . . ; 6 . . . . . . . . ; 5 . . . . . . . . ; 4 . . . . . . . . ; 3 . . . . . . . . ; 2 . . . . . . . . ; 1 . . . . . . . . ; a b c d e f g h "); computer = new Computer(bord, 1); zet = computer.BedenkBesteZet(); //Console.WriteLine("Zet: {0} eval:{1}",zet, computer.bestEval); Assert.IsTrue(false, "Zet: {0} eval:{1}", zet, computer.bestEval); throw new NotImplementedException(); }
public async Task GetZetByIdTestMetMockRepositorySuccesvol() { var testResult = new Zet { Id = 1, BeginVeld = 32, EindVeld = 28, PartijId = 1 }; //arrange var mockUnitOfWork = new Mock <IZetRepository>(); mockUnitOfWork.Setup(x => x.GetByIdAsync(1)).ReturnsAsync(testResult).Verifiable(); var service = new ZetService(mockUnitOfWork.Object); //Act var result = await service.GetZetById(1) as Zet; //Assert Assert.IsNotNull(result); Assert.AreEqual(32, result.BeginVeld); Assert.AreEqual(28, result.EindVeld); Assert.AreEqual(1, result.PartijId); }
public IActionResult Zet([FromBody] Zet zet) { Debug.WriteLine($"<<zet, Kolom: {zet.kolomZet} Rij: {zet.rijZet}>>"); Spel spel = iRepository.GetSpel(zet.Token); if (spel != null) { if (zet.Pas) { spel.Pas(); return(Ok("Passed")); } else { bool zetMogelijk = spel.DoeZet(zet.rijZet, zet.kolomZet); return(Ok(zetMogelijk)); } } else { return(NotFound()); } }
public Figure Creator() { Figure figure = new Zet(); return(figure); }
public async Task DeleteZet(Zet zet) { _zetRepository.Remove(zet); await _zetRepository.CommitAsync(); }
//public async Task<IEnumerable<Zet>> GetZettenByPartijId(int partijId) //{ // return await _unitOfWork.Zetten // .GetAllWithPartijByPartijIdAsync(partijId); //} public async Task CreateZet(Zet newZet) { await _zetRepository.AddAsync(newZet); await _zetRepository.CommitAsync(); }