public FightOutcome GetDecisionResult() { int wins = JudgeScores.Count(j => j.Fighter1Score > j.Fighter2Score); int losses = JudgeScores.Count(j => j.Fighter2Score > j.Fighter1Score); if (wins > losses) { return(FightOutcome.Win); } else if (losses > wins) { return(FightOutcome.Loss); } return(FightOutcome.Draw); }
public IActionResult OnPost(int?id) { JudgeQuestionsList = _unitOfWork.JudgeQuestions.GetAll(null, null, "Questions"); ApplicationObj = new Application(); PitchObj = new Pitch(); if (id != null) { ApplicationObj = _unitOfWork.Application.GetFirstOrDefault(u => u.ApplicantId == id); } PitchObj.ApplicationId = ApplicationObj.Id; PitchObj.Application = ApplicationObj; PitchObj.PitchDate = DateTime.Now; _unitOfWork.Pitch.Add(PitchObj); foreach (var judgeQuestion in JudgeQuestionsList) { JudgeScoresObj = new JudgeScores(); JudgeScoresObj.JudgeQuestionsId = judgeQuestion.JudgeQuestionsId; JudgeScoresObj.Score = Int32.Parse(Request.Form[judgeQuestion.JudgeQuestionsId.ToString()]); JudgeScoresObj.Comment = Request.Form["comment-" + judgeQuestion.JudgeQuestionsId.ToString()]; JudgeScoresObj.PitchId = PitchObj.PitchId; JudgeScoresObj.Pitch = PitchObj; _unitOfWork.JudgeScores.Add(JudgeScoresObj); } _unitOfWork.Save(); return(RedirectToPage("/Judge/PitchMeeting/PitchHistory/PitchHistoryDetails/Index", new { id = PitchObj.PitchId })); }