public ActionResult Save(Round round) { if (!ModelState.IsValid) { var viewModel = new RoundViewModel { Categories = _context.Categories.ToList(), Round = round }; } _context.Rounds.Add(round); _context.SaveChanges(); //Prepare details for candidates var lastRound = _context.Rounds.OrderByDescending(r => r.Id).FirstOrDefault(); var candidates = _context.Candidates .Where(r => r.CandidacyId == lastRound.CandidacyId && r.Period == lastRound.Period) .ToList(); foreach (var c in candidates) { var roundDetail = new RoundDetail(); roundDetail.IdHeader = lastRound.Id; roundDetail.CandidateId = c.Id; roundDetail.Votes = 0; _context.RoundsDetail.Add(roundDetail); } _context.SaveChanges(); return(RedirectToAction("Index")); }
public RoundViewModelTest() { _quizzes = GenerateQuizzesList(); _selectedQuizIndex = _random.Next(_quizzes.Count); _selectedQuiz = _quizzes[_selectedQuizIndex]; _selectedRoundIndex = _random.Next(_selectedQuiz.QuizRounds.Count); _selectedRound = _selectedQuiz.QuizRounds[_selectedRoundIndex]; _quizServiceMock = new Mock <IQuizService>(); _quizServiceMock.Setup(qS => qS.GetAllQuizzes()).ReturnsAsync(_quizzes); _quizServiceMock.Setup(qS => qS.DeleteQuiz(It.IsAny <int>())).ReturnsAsync(true); _quizServiceMock.Setup(qS => qS.EditQuiz(It.IsAny <int>(), It.IsAny <Quiz>())).ReturnsAsync(true); _roundServiceMock = new Mock <IRoundService>(); _roundServiceMock.Setup(rS => rS.EditRound(It.IsAny <int>(), It.IsAny <Round>())).ReturnsAsync(true); _navigationServiceExMock = new Mock <INavigationServiceEx>(); _navigationServiceExMock.Setup(nS => nS.GoBack()).Returns(true); _navigationServiceExMock.Setup(nS => nS.Navigate(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <NavigationTransitionInfo>())).Returns(true); _messengerCacheMock = new Mock <IMessengerCache>(); _messengerCacheMock.Setup(mC => mC.CachedSelectedQuiz).Returns(_selectedQuiz); _messengerCacheMock.Setup(mC => mC.CachedSelectedRound).Returns(_selectedRound); _sender = new QuizzenViewModel(_quizServiceMock.Object, _navigationServiceExMock.Object); _sender.EditQuizCommand.Execute(_selectedQuizIndex); _intermediate = new EditQuizViewModel(_quizServiceMock.Object, _navigationServiceExMock.Object, _messengerCacheMock.Object); _intermediate.NavigateToRoundCommand.Execute(_selectedRound); _sut = new RoundViewModel(_roundServiceMock.Object, _navigationServiceExMock.Object, _messengerCacheMock.Object); }
private void setUCGUI(RoundViewModel i_vmRound, int i_nNumberOfIndents) { string m_gamesDescription = ""; int iCount = 0; foreach (GameViewModel m_model in i_vmRound.m_vmGames.OrderBy(g => g.GameId)) { if ((m_model.HomePlayerScore >= 0) && (m_model.HomePlayerScore >= 0)) { m_gamesDescription += m_model.HomePlayerScore + "-" + m_model.AwayPlayerScore + ((m_model.hasSuddenDeath) ? "s" : ""); if ((iCount < i_vmRound.m_vmGames.Count() - 1) && (i_vmRound.m_vmGames[iCount + 1].HomePlayerScore >= 0) && (i_vmRound.m_vmGames[iCount + 1].AwayPlayerScore >= 0)) { m_gamesDescription += ","; } } iCount++; } lblGameResults.Text = m_gamesDescription; //Set overall game standings. if ((i_vmRound != null) && (i_vmRound.m_vmFirstGame.Count > 0)) { List <int> m_lstGamesWon = TableHockeyContestHandler.getNumberOfGamesWon(i_vmRound); i_vmRound.m_vmFirstGame[0].AwayPlayerScore = m_lstGamesWon[0]; i_vmRound.m_vmFirstGame[0].HomePlayerScore = m_lstGamesWon[1]; } //Indent control string m_sIndent = ""; for (int jCount = 0; jCount < i_nNumberOfIndents; jCount++) { m_sIndent += " "; } this.lblFiller.Text = m_sIndent; }
public void getUCGUI() { if (Session["ucContestRound.m_vmround"] != null) { m_vmRound = (RoundViewModel)Session["ucContestRound.m_vmround"]; } //Get results for each row and update TableHockeyGame table. for (int iCount = 0; iCount < this.GridViewContestRoundGames.Rows.Count; iCount++) { TextBox currentHomeScoreEntered = (TextBox)this.GridViewContestRoundGames.Rows[iCount].FindControl("TextBoxHomePlayerScore"); TextBox currentAwayScoreEntered = (TextBox)this.GridViewContestRoundGames.Rows[iCount].FindControl("TextBoxAwayPlayerScore"); int m_nCurrentGameId = Convert.ToInt32(this.GridViewContestRoundGames.Rows[iCount].Cells[0].Text); int m_nHomeScore = -1; if ((int.TryParse(currentHomeScoreEntered.Text, out m_nHomeScore)) && m_nHomeScore >= 0) { m_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).HomePlayerScore = Convert.ToInt32(currentHomeScoreEntered.Text); } else { m_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).HomePlayerScore = -1; } int m_nAwayScore = -1; if ((int.TryParse(currentAwayScoreEntered.Text, out m_nAwayScore)) && m_nAwayScore >= 0) { m_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).AwayPlayerScore = Convert.ToInt32(currentAwayScoreEntered.Text); } else { m_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).AwayPlayerScore = -1; } } Session["ucContestRound.m_vmround"] = m_vmRound; m_games = m_vmRound.m_vmGames; }
public ActionResult DeleteConfirmed(int id) { RoundViewModel roundViewModel = db.Round.Find(id); db.Round.Remove(roundViewModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> StartNextRoundForDealer(RoundViewModel rounds) { var result = await _gameService.StartNextRoundForDealer(rounds.Users); ModelState.Clear(); return(View(result)); }
public void DataShow(RoundViewModel i_round, int i_nNumberOfIndents) { setUCGUI(m_vmRound, i_nNumberOfIndents); Session["ucEndGameSeries.m_vmround"] = m_vmRound; m_games = m_vmRound.m_vmGames; this.GridViewEndGameOverview.DataSource = m_vmRound.m_vmFirstGame; this.GridViewEndGameOverview.DataBind(); }
public IActionResult Index(RoundViewModel roundViewModel) { if (roundViewModel == null) { return(NotFound()); } return(View(roundViewModel)); }
public void Constructor_ShouldLoadSelectedRound() { //Act var sut = new RoundViewModel(_roundServiceMock.Object, _navigationServiceExMock.Object, _messengerCacheMock.Object); //Assert Assert.Equal(_selectedRound, sut.SelectedRound); }
public async Task <IActionResult> TriggerRound(int?id) { Game game = await _gameService.GetGame(); RoundViewModel roundViewModel = new RoundViewModel(game); return(View(roundViewModel)); }
public async Task <RoundViewModel> GetRoundAsync() { var game = await _context.Games .FirstOrDefaultAsync(); RoundViewModel roundViewModel = new RoundViewModel(game); return(roundViewModel); }
public void DataShow(RoundViewModel i_round) { this.GridViewEndGames.DataSource = m_vmRound.m_vmGames; this.GridViewEndGames.DataBind(); setUCGUI(m_vmRound); Session["ucEndGameSeries.m_vmround"] = m_vmRound; m_games = m_vmRound.m_vmGames; this.GridViewEndGameOverview.DataSource = m_vmRound.m_vmFirstGame; this.GridViewEndGameOverview.DataBind(); }
public RoundViewModel Post([FromBody] RoundViewModel roundView) { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(null); } return(SaveRound(roundView)); }
public void InitControl(TableHockeyContestRound i_TableHockeyRound) { if (i_TableHockeyRound != null) { m_round = i_TableHockeyRound; Session["ucEndGameSeries.m_round"] = m_round; } m_vmRound = new RoundViewModel(m_round); DataShow(m_vmRound); }
public ActionResult Edit([Bind(Include = "RoundId,CourseId,HoleScore")] RoundViewModel roundViewModel) { if (ModelState.IsValid) { db.Entry(roundViewModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Course, "CourseId", "CourseName", roundViewModel.CourseId); return(View(roundViewModel)); }
public ActionResult Create([Bind(Include = "RoundId,CourseId,HoleScore")] RoundViewModel roundViewModel) { if (ModelState.IsValid) { db.Round.Add(roundViewModel); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Course, "CourseId", "CourseName", roundViewModel.CourseId); return(View(roundViewModel)); }
private RoundViewModel ConvertRoundVM(Round round) { List <SetViewModel> setViewModels = new List <SetViewModel>(); foreach (var set in round.GetSets()) { setViewModels.Add(ConvertSetVM(set)); } RoundViewModel roundViewModel = new RoundViewModel(); return(roundViewModel); }
public async Task <ActionResult> StartNextRoundForPlayers(RoundViewModel rounds) { var result = await _gameService.StartNextRoundForPlayers(rounds.Users); ModelState.Clear(); //if (result.isResultComplete) //{ // return View("GameFinnished", result); //} return(PartialView(result)); }
// GET: Ronda public ActionResult Index() { ViewBag.rounds = _context.Rounds.ToList(); var viewModel = new RoundViewModel { Round = new Round(), Categories = _context.Categories.ToList(), Candidacies = _context.Candidacys.ToList() }; return(View("Rounds", viewModel)); }
// GET: RoundViewModels/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RoundViewModel roundViewModel = db.Round.Find(id); if (roundViewModel == null) { return(HttpNotFound()); } return(View(roundViewModel)); }
private void setUCGUI(RoundViewModel i_vmRound) { //Set scores in Gridview tbs. //Get results for each row and update TableHockeyGame table. int m_nNumberOfGamesWonHome = 0; int m_nNumberOfGamesWonAway = 0; for (int iCount = 0; iCount < this.GridViewEndGames.Rows.Count; iCount++) { TextBox currentHomeScore = (TextBox)this.GridViewEndGames.Rows[iCount].FindControl("TextBoxHomePlayerScore"); TextBox currentAwayScore = (TextBox)this.GridViewEndGames.Rows[iCount].FindControl("TextBoxAwayPlayerScore"); int m_nCurrentGameId = Convert.ToInt32(this.GridViewEndGames.Rows[iCount].Cells[0].Text); int m_nHomeScore = i_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).HomePlayerScore; int m_nAwayScore = i_vmRound.m_vmGames.Find(g => g.GameId == m_nCurrentGameId).AwayPlayerScore; if (m_nHomeScore >= 0) { currentHomeScore.Text = Convert.ToString(m_nHomeScore); } else { currentHomeScore.Text = ""; } if (m_nAwayScore >= 0) { currentAwayScore.Text = Convert.ToString(m_nAwayScore); } else { currentAwayScore.Text = ""; } if ((m_nHomeScore >= 0) && (m_nAwayScore >= 0)) { if (m_nHomeScore > m_nAwayScore) { m_nNumberOfGamesWonHome++; } if (m_nAwayScore > m_nHomeScore) { m_nNumberOfGamesWonAway++; } } } //Set overall game standings. if ((i_vmRound != null) && (i_vmRound.m_vmFirstGame.Count > 0)) { i_vmRound.m_vmFirstGame[0].HomePlayerScore = m_nNumberOfGamesWonHome; i_vmRound.m_vmFirstGame[0].AwayPlayerScore = m_nNumberOfGamesWonAway; } }
public void InitControl(TableHockeyContestRound i_TableHockeyRound) { if (i_TableHockeyRound != null) { m_round = i_TableHockeyRound; Session["ucContestRound.m_round"] = m_round; } m_vmRound = new RoundViewModel(m_round); this.GridViewContestRoundGames.DataSource = m_vmRound.m_vmGames; this.GridViewContestRoundGames.DataBind(); Session["ucContestRound.m_vmround"] = m_vmRound; m_games = m_vmRound.m_vmGames; setUCGUI(); }
private RoundDTO ConvertRoundVM(RoundViewModel roundViewModel) { List <SetDTO> sets = new List <SetDTO>(); foreach (var set in roundViewModel.Sets) { set.SetOrder = roundViewModel.Sets.IndexOf(set); sets.Add(ConvertSetVM(set)); } UserCollection userCollection = new UserCollection(); ExerciseDTO exercise = userCollection.GetExercise(roundViewModel.Exercise.Name); RoundDTO round = new RoundDTO(exercise, exercise.ExerciseID, sets); return(round); }
// GET: RoundViewModels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RoundViewModel roundViewModel = db.Round.Find(id); if (roundViewModel == null) { return(HttpNotFound()); } ViewBag.CourseId = new SelectList(db.Course, "CourseId", "CourseName", roundViewModel.CourseId); return(View(roundViewModel)); }
// GET: Round public ActionResult Play() { Round currentRound = _gameService.StartRoundOrGetExisting(GetUserIdFromSessionStorage()); RoundViewModel roundViewModel = new RoundViewModel { Images = currentRound.Images.Select(i => new ImageViewModel { Url = i.Url, Id = i.Id }).ToList(), Name = currentRound.Name, RoundIndex = currentRound.AmountOfRoundsPlayed + 1, TotalRounds = currentRound.TotalRounds }; return(View(roundViewModel)); }
//private Random _rnd = new Random(); //public string drawNumbers(int numLimit, int numAmount) //{ // return string.Join(",", // Enumerable // .Range(1, numLimit) // .OrderBy(x => _rnd.Next()) // .Take(numAmount)); //} public RoundViewModel ActivateRound() { var round = new RoundViewModel() { WinningCombination = _helper.GenerateNumbers(37, 7) }; var createdRound = new RoundResults() { WinningCombination = round.WinningCombination }; _roundRepository.CreateRound(createdRound); return(round); }
public IActionResult Rounds(int id) { var users = userManager.Users .OrderBy(x => x.ShortName) .ToList(); var matches = roundService.GetMatches(id); var mappedUsers = mapper.Map <List <UserDetailsViewModel> >(users); var currentUserId = userManager.GetUserId(User); var isAdmin = User.IsInRole(Constants.ROLE_ADMIN); roundService.ArrangeScoreBets(matches, mappedUsers, currentUserId, isAdmin); var roundPoints = roundService.GetRoundResults(matches, users.Count); var bonusPoints = roundService.GetBonusResults(roundPoints); var totalPoints = roundService.GetTotalResults(roundPoints, bonusPoints); if (id > 1) { for (int i = 1; i < id; i++) { var prevRoundPoints = roundService.GetRoundResults(i); var prevBonusPoints = roundService.GetBonusResults(prevRoundPoints); var prevTotalPoints = roundService.GetTotalResults(prevRoundPoints, prevBonusPoints); totalPoints = roundService.JoinTotalResults(prevTotalPoints, totalPoints); } } var groupPoints = groupService.GetRoundResults(); var groupBonusPoints = roundService.GetBonusResults(groupPoints); totalPoints = roundService.JoinTotalResults(roundService.GetTotalResults(groupPoints, groupBonusPoints), totalPoints); roundService.AddCurrentTimeDelimiter(ref matches); var model = new RoundViewModel() { Title = roundService.GetRoundTitle(id), Users = mappedUsers, Matches = matches, RoundPoints = roundPoints, BonusPoints = bonusPoints, TotalPoints = totalPoints }; return(View(model)); }
private RoundViewModel SaveRound(RoundViewModel roundView) { Round round = roundView.ToBaseModel(); roundBll.SaveRound(round); roundBll.FillGames = true; round = roundBll.GetRound(round.Id); roundView = round.ToViewModel(); var roundVMHelper = new RoundVMHelper(new RoundViewModel[] { roundView }); roundVMHelper.FillAvailableTeams(); return(roundView); }
private RoundViewModel ConvertRoundDTO(RoundDTO roundDTO) { List <SetViewModel> setViewModels = new List <SetViewModel>(); foreach (var setDTO in roundDTO.GetSets()) { setViewModels.Add(ConvertSetDTO(setDTO)); } ; RoundViewModel roundViewModel = new RoundViewModel { Exercise = ConvertExerciseDTOToVM(roundDTO.Exercise), ExerciseID = roundDTO.ExerciseID, RoundID = roundDTO.RoundID, TrainingID = roundDTO.TrainingID, Sets = setViewModels }; return(roundViewModel); }
public IActionResult Index(int gameId) { var currentGame = _showViewsRepo._db.Games .Include(g => g.GamePlayers) .ThenInclude(gp => gp.Player) .Include(g => g.GameRounds) .ThenInclude(gr => gr.GRPs) .FirstOrDefault(p => p.GamesId == gameId); if (currentGame == null) { return(NotFound()); } var viewModel = new RoundViewModel() { CurrentGame = currentGame }; return(View(viewModel)); }