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 Quantity CreateANewQuantity(int amount, int unitId) { DataBaseRepo database = new DataBaseRepo(); var result = (DatabaseHolder)database.Save(new Quantity { Amount = amount, UnitId = unitId }); var quantity = (Quantity)database.GetObject(result.PrimaryKey.ToString(), new Quantity()); return(quantity); }
public void SaveToTable() { //var timePeriod = new TimePeriod { StartDate=DateTime.Now, EndDate=DateTime.Parse("2018-05-28 07:00") }; var party = new ContestType { Name = "Träningstävling" }; var dbRepo = new DataBaseRepo(); var result = (DatabaseHolder)dbRepo.Save(party); Assert.Equal(ExecuteCodes.SuccessToExecute, result.ExecuteCodes); }
public Party CreateANewManager(string legalId, string name, string address, bool isManager = true) { var member = new Party { Address = address, IsManager = isManager, LegalId = legalId, Name = name }; var dataBase = new DataBaseRepo(); var databaseHolder = (DatabaseHolder)dataBase.Save(member); member.PartyId = databaseHolder.PrimaryKey; return(member); }
public void CreateANewContest(int[] competitors, int managerId, int timePeriodId, int contestTypeId) { var compId = new List <int>(); var database = new DataBaseRepo(); var contest = new Contest { ContestTypeId = contestTypeId, ManagerId = managerId, TimePeriodId = timePeriodId, WinnerId = 0 }; var databaseHolder = (DatabaseHolder)database.Save(contest); for (int i = 0; i < competitors.Length; i++) { ContestParticipants contestParticipants = new ContestParticipants { ContestId = databaseHolder.PrimaryKey, CompetitorId = competitors[i] }; database.Save(new ContestParticipants()); compId.Add(competitors[i]); if (compId.Count == 2 && i > 0) { var match = new Match { ContestId = databaseHolder.PrimaryKey }; match.CreateLanes(compId, databaseHolder.PrimaryKey, match); compId.Clear(); } if (i % 2 == 1 && i == competitors.Length) { databaseHolder = (DatabaseHolder)database.Save(contest); var match = new Match(); var matchId = (DatabaseHolder)database.Save(match); match.MatchId = matchId.PrimaryKey; match.CreateLanes(compId, databaseHolder.PrimaryKey, match); compId.Clear(); } } }
//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); } }