public void CreateLanes(List <int> competitorsId, int contestId, Match match) { var database = new DataBaseRepo(); var unitService = new MeasurementService(); var unit = unitService.WhatUnitDoYouNeedBro("spelare"); //TODO Bygga upp serier genom lane, även få med båda spelarnas ID:n så att det skapas en separat serie per spelare. var quantity = (DatabaseHolder)database.Save (new Quantity { Amount = 2, UnitId = unit.UnitId }); if (quantity.ExecuteCodes == ExecuteCodes.SuccessToExecute) { var lane = new Lane { UnitId = unit.UnitId, QuantityId = quantity.PrimaryKey }; var primaryKeyLane = (DatabaseHolder)database.Save(lane); match.LaneId = primaryKeyLane.PrimaryKey; match.QuantityId = quantity.PrimaryKey; match.UnitId = unit.UnitId; var matchId = (DatabaseHolder)database.Save(match); if (matchId.ExecuteCodes != ExecuteCodes.FailedToExecute) { lane.CreateSerie(primaryKeyLane.PrimaryKey, contestId, competitorsId); } } }
public void GetAUnitByName() { MeasurementService sut = new MeasurementService(); var result = sut.WhatUnitDoYouNeedBro("SpElare"); var unit = new Unit { Name = "Spelare" }; Assert.Equal(unit.Name, result.Name); }
//public Match Match { get; set; } //public Score Score { get; set; } //public List<Serie> Series { get; set; } public void CreateSerie(int laneId, int contestId, List <int> compIds) { var measurementService = new MeasurementService(); var unit = measurementService.WhatUnitDoYouNeedBro("poäng"); var quantity = measurementService.CreateANewQuantity(0, unit.UnitId); var database = new DataBaseRepo(); for (int i = 0; i < compIds.Count; i++)//To get three series and three scores. { for (int j = 3; j > 0; j--) { var serie = new Serie { LaneId = laneId, PartyId = compIds[i], TurnCounter = 10, ContestId = contestId }; var dataHolderSerie = (DatabaseHolder)database.Save(serie); var score = new Score { LaneId = laneId, UnitId = unit.UnitId, QuantityId = quantity.QuantityId, SerieId = dataHolderSerie.PrimaryKey }; var dataHolderScore = (DatabaseHolder)database.Save(score); } //serie.PlayRound(dataHolderScore.PrimaryKey); } }