public void MapModelToBO() { var mapper = new BOLTeamMapper(); ApiTeamRequestModel model = new ApiTeamRequestModel(); model.SetProperties("A", 1); BOTeam response = mapper.MapModelToBO(1, model); response.Name.Should().Be("A"); response.OrganizationId.Should().Be(1); }
public void MapBOToModel() { var mapper = new BOLTeamMapper(); BOTeam bo = new BOTeam(); bo.SetProperties(1, "A", 1); ApiTeamResponseModel response = mapper.MapBOToModel(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); response.OrganizationId.Should().Be(1); }
public void MapEFToBO() { var mapper = new DALTeamMapper(); Team entity = new Team(); entity.SetProperties(1, "A", 1); BOTeam response = mapper.MapEFToBO(entity); response.Id.Should().Be(1); response.Name.Should().Be("A"); response.OrganizationId.Should().Be(1); }
public void MapBOToEF() { var mapper = new DALTeamMapper(); var bo = new BOTeam(); bo.SetProperties(1, "A", 1); Team response = mapper.MapBOToEF(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); response.OrganizationId.Should().Be(1); }
public void MapBOToModelList() { var mapper = new BOLTeamMapper(); BOTeam bo = new BOTeam(); bo.SetProperties(1, "A", 1); List <ApiTeamResponseModel> response = mapper.MapBOToModel(new List <BOTeam>() { { bo } }); response.Count.Should().Be(1); }
public void AddMatch(long teamA, long teamB, bool winner) { int result = winner ? 1 : 0; double expectedOutcomeA = CalculateExpectedOutcome(teamA, teamB, 1); double expectedOutcomeB = CalculateExpectedOutcome(teamB, teamA, 1); BOTeam team1 = new BOTeam(teamA); BOTeam team2 = new BOTeam(teamB); team1.ELOValue = (long)Math.Round(team1.ELOValue + _K_VALUE * (result - expectedOutcomeA)); team2.ELOValue = (long)Math.Round(team2.ELOValue + _K_VALUE * ((1 - result) - expectedOutcomeB)); team1.Save(); team2.Save(); }
public ActionResult Create(TeamViewModel model) { if (ModelState.IsValid) { var businessObject = new BOTeam(); Mapper.Map<TeamViewModel, BOTeam>(model, businessObject); businessObject.Game = new BOGame(model.GameListID); _teamService.Save(businessObject); return RedirectToAction("Index"); } model.GameList = new SelectList (_gameService.GetAll(), SelectLists.DataValueField, SelectLists.DataTextField, SelectLists.UnitializedSelectValue); return View(model); }
public void MapModelToBO() { var mapper = new BOLTeamMapper(); ApiTeamRequestModel model = new ApiTeamRequestModel(); model.SetProperties("A", "A", "A", "A", "A", "A", "A", "A"); BOTeam response = mapper.MapModelToBO("A", model); response.EnvironmentIds.Should().Be("A"); response.JSON.Should().Be("A"); response.MemberUserIds.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupIds.Should().Be("A"); response.ProjectIds.Should().Be("A"); response.TenantIds.Should().Be("A"); response.TenantTags.Should().Be("A"); }
public void MapBOToModel() { var mapper = new BOLTeamMapper(); BOTeam bo = new BOTeam(); bo.SetProperties("A", "A", "A", "A", "A", "A", "A", "A", "A"); ApiTeamResponseModel response = mapper.MapBOToModel(bo); response.EnvironmentIds.Should().Be("A"); response.Id.Should().Be("A"); response.JSON.Should().Be("A"); response.MemberUserIds.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupIds.Should().Be("A"); response.ProjectIds.Should().Be("A"); response.TenantIds.Should().Be("A"); response.TenantTags.Should().Be("A"); }
public void MapEFToBO() { var mapper = new DALTeamMapper(); Team entity = new Team(); entity.SetProperties("A", "A", "A", "A", "A", "A", "A", "A", "A"); BOTeam response = mapper.MapEFToBO(entity); response.EnvironmentIds.Should().Be("A"); response.Id.Should().Be("A"); response.JSON.Should().Be("A"); response.MemberUserIds.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupIds.Should().Be("A"); response.ProjectIds.Should().Be("A"); response.TenantIds.Should().Be("A"); response.TenantTags.Should().Be("A"); }
public void MapBOToEF() { var mapper = new DALTeamMapper(); var bo = new BOTeam(); bo.SetProperties("A", "A", "A", "A", "A", "A", "A", "A", "A"); Team response = mapper.MapBOToEF(bo); response.EnvironmentIds.Should().Be("A"); response.Id.Should().Be("A"); response.JSON.Should().Be("A"); response.MemberUserIds.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupIds.Should().Be("A"); response.ProjectIds.Should().Be("A"); response.TenantIds.Should().Be("A"); response.TenantTags.Should().Be("A"); }
public void Save(BOTeam team) { _teamRepository.Save(team); }
public double CalculateExpectedOutcomeFast(BOTeam teamA, BOTeam teamB, int matches) { long diff = (teamB.ELOValue - teamA.ELOValue); double expectedOutcome = 1 / (1 + Math.Pow(10, ((double)diff / 400))); int matchesToWin = (int)Math.Ceiling((((decimal)matches) / 2)); return correctBinomial(expectedOutcome, matchesToWin, matches); }
public double CalculateExpectedOutcome(long teamA, long teamB, int matches) { BOTeam team1 = new BOTeam(teamA); BOTeam team2 = new BOTeam(teamB); long diff = team2.ELOValue - team1.ELOValue; double expectedOutcome = 1 / (1 + Math.Pow(10, ((double)diff / 400))); int matchesToWin = (int)Math.Ceiling((((decimal)matches) / 2)); return correctBinomial(expectedOutcome, matchesToWin, matches); }
public BOTeamComparer(BOTeam.Columns column, BOTeam.SortDirections direction) { _column = column; _direction = direction; }
/// <summary> /// Internal 0:Needs to be processed, 1:processing, 2:live event, 3:done, 4:elo done /// </summary> public void Process() { if (InternalStatus == 3 || InternalStatus == 1) return; if (InternalStatus == 0) InternalStatus = 1; Save(); // This code needs to be moved WebClient Client = new WebClient(); HTML = Client.DownloadString(this.URL); HtmlDocument document = new HtmlDocument(); document.LoadHtml(HTML); HtmlNodeCollection matches = document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[1].SelectNodes("tr"); if (matches != null) { long roundNumberPrevious = 0; BOMatch match = new BOMatch(); foreach (HtmlNode row in matches) { var columns = row.SelectNodes("td"); string link = columns[0].FirstChild.Attributes["href"].Value; string externalID = columns[0].InnerText; DateTime date = DateTime.Parse(columns[1].InnerText); string Team1Short = columns[2].InnerText; string Team1URL = columns[2].FirstChild.Attributes["href"].Value; string Team2Short = columns[3].InnerText; string Team2URL = columns[3].FirstChild.Attributes["href"].Value; string winningSide = columns[4].InnerText; long roundNubmer; if (!string.IsNullOrEmpty(columns[6].InnerText)) roundNubmer = long.Parse(columns[6].InnerText); else roundNubmer = 1; float gameTime = float.Parse(columns[7].InnerText); int scoreTeam1 = int.Parse(columns[8].InnerText.Split('-')[0].Trim()); int scoreTeam2 = int.Parse(columns[8].InnerText.Split('-')[1].Trim()); if (BOMatch.CheckExistingExternalID(long.Parse(externalID))) { BORound round = new BORound(); round.Winner = winningSide.ToUpper().Contains("RADIANT"); round.ScoreTeam1 = scoreTeam1; round.ScoreTeam2 = scoreTeam2; round.GameLengthMinutes = (int)gameTime; if (roundNumberPrevious <= roundNubmer) {// create a new match match = new BOMatch(); match.Status = 1; match.Event = this; } round.ExternalID = long.Parse(externalID); round.Match = match; BOTeam t1 = BOTeam.GetByName(Team1Short); if(t1 == null) { t1 = new BOTeam(); t1.Name = Team1Short; t1.Game = this.Game; t1.ELOValue = BOTeam.DefaultELOValue; t1.Save(); } BOTeam t2 = BOTeam.GetByName(Team2Short); if (t2 == null) { t2 = new BOTeam(); t2.Name = Team2Short; t2.Game = this.Game; t2.ELOValue = BOTeam.DefaultELOValue; t2.Save(); } round.RNDTeam1Team = t1; round.RNDTeam2Team = t2; round.OddsforTeam1 = 0; round.BetsforTeam1 = 1; match.Format = new BOFormat(1); match.InternalStatus = 1; match.Date = date; round.Date = date; round.ELO1 = 0; round.ELO2 = 0; match.Save(); round.Save(); roundNumberPrevious = roundNubmer; } } } }