override public string ToString() { string retString = ""; retString += FirstRound.ToString(); retString += SecondRound.ToString(); retString += FinalQuestion.ToString(); return(retString); }
public SecondRoundViewModel(SecondRound model) { if (model != null) { Id = model.Id; if (model.Questions != null) { Questions = model.Questions.Select(x => new TruthQuestionViewModel(x)).ToList(); } } }
public async Task <ServiceResult> EditSecondRound(int gameId, SecondRoundEditViewModel model) { var game = await GetGameByPlayerRoles(gameId, PlayerRole.Creator); if (!game.IsSuccess) { return(Error(game.ErrorMessage)); } SecondRound secondRound = game.Data.SecondRound; if (secondRound == null) { secondRound = new SecondRound(); game.Data.SecondRound = secondRound; } var index = 0; if (model.Questions.Count < secondRound.Questions.Count) { secondRound.Questions.RemoveRange(model.Questions.Count, secondRound.Questions.Count - model.Questions.Count); } var count = secondRound.Questions.Count; foreach (var questionModel in model.Questions) { if (index < count) { var question = secondRound.Questions[index]; question.Value = model.Questions[index].Value; question.IsTruth = model.Questions[index].IsTruth; question.Index = index; } else { var question = new TruthQuestion { Value = model.Questions[index].Value, IsTruth = model.Questions[index].IsTruth, Index = index }; secondRound.Questions.Add(question); } index++; } await context.SaveChangesAsync(); return(Success()); }