public async Task <IActionResult> TopScorer() { var viewModel = new ScorerViewModel(); var myTeamEnumName = GetMyCurrentEnumTeamName(); var myTeamId = Convert.ToInt32(myTeamEnumName); var teamUri = "v2/teams/" + myTeamId; var myTeam = await GetFootballDataResources(new Team(), teamUri); var competitionIds = myTeam.ActiveCompetitions .Where(a => a.Plan == "TIER_ONE") .Select(a => a.Id).ToList(); foreach (var competitionId in competitionIds) { var uri = "v2/competitions/" + competitionId + "/scorers"; viewModel.ScorerStandings.Add(await GetFootballDataResources(new ScorerStandings(), uri)); } return(View(viewModel)); }
public IHttpActionResult GetDetails(string id) { ScorerDetails modelDetails = new ScorerDetails(); ScorerViewModel mainModel = new ScorerViewModel(); DataTable dt = null; db.openConnection(); try { if (id.All(char.IsDigit)) { paramName = new string[] { "pIdGoleador" }; paramValue = new string[] { id }; dt = db.executePROC("spGetGoleadorByGoleador", paramName, paramValue); if (dt.Rows.Count > 0) { if (dt.Rows[0]["NM_TIPO_TIME"].ToString() == "PRO CLUB") { modelDetails.scorerType = "PRO"; } else { modelDetails.scorerType = "H2H"; } modelDetails.id = Convert.ToInt32(id); modelDetails.teamID = Convert.ToInt16(dt.Rows[0]["ID_TIME"].ToString()); modelDetails.DateSubscriptionFormatted = dt.Rows[0]["DT_FORMATADA"].ToString(); modelDetails.nickname = dt.Rows[0]["NM_GOLEADOR"].ToString(); modelDetails.name = dt.Rows[0]["NM_GOLEADOR_COMPLETO"].ToString(); modelDetails.country = dt.Rows[0]["DS_PAIS"].ToString(); modelDetails.link = dt.Rows[0]["DS_LINK_IMAGEM"].ToString(); if (!String.IsNullOrEmpty(dt.Rows[0]["ID_TIME_SOFIFA"].ToString())) { modelDetails.sofifaTeamID = dt.Rows[0]["ID_TIME_SOFIFA"].ToString(); } modelDetails.rating = dt.Rows[0]["IN_RATING"].ToString(); if (!String.IsNullOrEmpty(dt.Rows[0]["ID_USUARIO"].ToString())) { modelDetails.userID = Convert.ToInt32(dt.Rows[0]["ID_USUARIO"].ToString()); } if (!String.IsNullOrEmpty(dt.Rows[0]["DT_INSCRICAO"].ToString())) { modelDetails.DateSubscription = Convert.ToDateTime(dt.Rows[0]["DT_INSCRICAO"].ToString()); } } modelDetails.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelDetails)); } else { paramName = new string[] { }; paramValue = new string[] { }; if (id == "H2H") { dt = db.executePROC("spGetAllGoleadoresNoFilterCRUDH2H", paramName, paramValue); } else { dt = db.executePROC("spGetAllGoleadoresNoFilterCRUDPRO", paramName, paramValue); } mainModel.scorerType = id; mainModel.listOfScorer = setUpListDetailsScorers(dt); mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } } catch (Exception ex) { modelDetails.returnMessage = "errorGetScorer_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelDetails)); } finally { db.closeConnection(); modelDetails = null; dt = null; mainModel = null; } }
public IHttpActionResult postRequest(ScorerDetails model) { ScorerViewModel mainModel = new ScorerViewModel(); CurrentSeasonSummaryViewModel mainViewModel = new CurrentSeasonSummaryViewModel(); db.openConnection(); DataTable dt = null; try { if (model.actionUser == "save") { if (model.id > 0) { paramName = new string[] { "pIdGoleador", "pIdTime", "pNmGoleador", "pNmCompleto", "pDsLink", "pDsPais", "pIdSofifa", "pIdUsu" }; paramValue = new string[] { Convert.ToString(model.id), Convert.ToString(model.teamID), model.nickname, model.name, model.link, model.country, model.sofifaTeamID, Convert.ToString(model.userID) }; dt = db.executePROC("spUpdateGoleador", paramName, paramValue); } else { paramName = new string[] { "pIdGoleador", "pIdTime", "pNmGoleador", "pNmCompleto", "pDsLink", "pDsPais", "pIdSofifa", "pTipo", "pIdUsu" }; paramValue = new string[] { "0", Convert.ToString(model.teamID), model.nickname, model.name, model.link, model.country, model.sofifaTeamID, model.scorerType, Convert.ToString(model.userID) }; dt = db.executePROC("spAddGoleador", paramName, paramValue); } model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getListOfScorerByTeam") { paramName = new string[] { "pIdTime" }; paramValue = new string[] { Convert.ToString(model.teamID) }; dt = db.executePROC("spGetAllGoleadorByTime", paramName, paramValue); mainModel.listOfScorer = setUpListDetailsScorers(dt); mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else if (model.actionUser == "getListOfScorerByChampionship") { mainViewModel.listOfScorers = GlobalFunctions.getListScorers(String.Empty, db, 0, false, model.id); mainViewModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainViewModel)); } else if (model.actionUser == "getListOfScorerByMatchTeam") { paramName = new string[] { "pIdJogo", "pIdTime" }; paramValue = new string[] { Convert.ToString(model.id), Convert.ToString(model.teamID) }; dt = db.executePROC("spGetGoleadorGolsOfTime", paramName, paramValue); mainModel.listOfScorer = setUpListDetailsScorers(dt); mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; mainModel = null; mainViewModel = null; } }
public ScorerPage() { InitializeComponent(); BindingContext = new ScorerViewModel(); }
private ScorerViewModel BuildViewModel(int shotId) { var shot = _db.Shots.Find(shotId); var shoot = shot.Shoot; var viewModel = new ScorerViewModel { ShootId = shoot.Id, ShotId = shotId, Score = shot.Score, Sighter = false, FinalSighter = false, // default, conditionally updated below ShotNumber = shot.ShotNumber, RegisterCardId = shoot.RegisterCardId, TeamCompetitorId = shoot.TeamCompetitorId, Distance = shoot.Distance, CompetitorName = shoot.CompetitorName, CompetitionName = shoot.CompetitionName }; if (shot is SightingShot) { viewModel.Sighter = true; if (shot.ShotNumber == 1) // first sighter { viewModel.PreviousShotId = null; } else { viewModel.PreviousShotId = shoot.Sighters.Single(s => s.ShotNumber == shot.ShotNumber - 1).Id; } if (shot.ShotNumber == shoot.Sighters.Count()) // last sighter { viewModel.FinalSighter = true; viewModel.NextShotId = shoot.ScoringShots.Single(s => s.ShotNumber == 1).Id; } else { viewModel.NextShotId = shoot.Sighters.Single(s => s.ShotNumber == shot.ShotNumber + 1).Id; } } else // scoring shot { if (shot.ShotNumber == 1) // first to count { viewModel.PreviousShotId = shoot.Sighters.Single(s => s.ShotNumber == shoot.Sighters.Count()).Id; } else { viewModel.PreviousShotId = shoot.ScoringShots.Single(s => s.ShotNumber == shot.ShotNumber - 1).Id; } if (shot.ShotNumber == shoot.ScoringShots.Count()) // last to count { viewModel.NextShotId = null; } else { viewModel.NextShotId = shoot.ScoringShots.Single(s => s.ShotNumber == shot.ShotNumber + 1).Id; } } return(viewModel); }