public async Task <JsonResult> SaveWinners(List <ForEvaluationViewModel> model) { var returnValue = new DbResult() { IsSuccess = false, ErrorMessage = "Invalid model" }; if (_evaluatorService.IsValid(model.Count)) { int winnerId = await _evaluatorService.Evaluate(model.Select(m => m.Hand_Id).ToList()); var forSaving = model.Where(m => m.Hand_Id == winnerId).ToList(); Dictionary <int, List <int> > groupOfPlayers = new Dictionary <int, List <int> >(); for (int index = 0; index < forSaving.Count; index++) { groupOfPlayers.Add(index, forSaving[index].Player_Ids); } returnValue = await _evaluatorService.SaveWinners(winnerId, groupOfPlayers); returnValue.Data = winnerId; } else { returnValue.ErrorMessage = "Items count should be greater than or equal to 2 and less than or equal to 5."; } return(Json(returnValue)); }
public void Hand_Count_Less_Than_Two() { int groupCount = 1; Assert.IsFalse(_evaluatorService.IsValid(groupCount), "Count should be greater than or equalt 2."); }