public static BodyType DetectBodyTypeFromContentType([CanBeNull] string contentTypeValue) { if (string.IsNullOrEmpty(contentTypeValue) || !MediaTypeHeaderValue.TryParse(contentTypeValue, out MediaTypeHeaderValue contentType)) { return(BodyType.Bytes); } if (TextContentTypeMatchers.Any(matcher => MatchScores.IsPerfect(matcher.IsMatch(contentType.MediaType)))) { return(BodyType.String); } if (JsonContentTypesMatchers.Any(matcher => MatchScores.IsPerfect(matcher.IsMatch(contentType.MediaType)))) { return(BodyType.Json); } if (MultipartContentTypesMatchers.Any(matcher => MatchScores.IsPerfect(matcher.IsMatch(contentType.MediaType)))) { return(BodyType.MultiPart); } return(BodyType.Bytes); }
private double IsMatch(RequestMessage requestMessage) { if (Funcs != null) { return(MatchScores.ToScore(requestMessage.Query != null && Funcs.Any(f => f(requestMessage.Query)))); } WireMockList <string> valuesPresentInRequestMessage = requestMessage.GetParameter(Key); if (valuesPresentInRequestMessage == null) { // Key is not present at all, just return Mismatch return(MatchScores.Mismatch); } if (Matchers != null && Matchers.Any()) { // Matchers are defined, just use the matchers to calculate the match score. var scores = new List <double>(); foreach (string valuePresentInRequestMessage in valuesPresentInRequestMessage) { double score = Matchers.Max(m => m.IsMatch(valuePresentInRequestMessage)); scores.Add(score); } return(scores.Any() ? scores.Average() : MatchScores.Mismatch); } if (Matchers == null || !Matchers.Any()) { // Matchers are null or not defined, and Key is present, just return Perfect. return(MatchScores.Perfect); } return(MatchScores.Mismatch); }
private double CalculateMatchScore(IRequestMessage requestMessage) { if (Matchers != null && Matchers.Any()) { return(Matchers.Max(matcher => CalculateMatchScore(requestMessage, matcher))); } if (Func != null) { return(MatchScores.ToScore(Func(requestMessage?.BodyData?.BodyAsString))); } if (JsonFunc != null) { return(MatchScores.ToScore(JsonFunc(requestMessage?.BodyData?.BodyAsJson))); } if (DataFunc != null) { return(MatchScores.ToScore(DataFunc(requestMessage?.BodyData?.BodyAsBytes))); } return(MatchScores.Mismatch); }
private double IsMatch(RequestMessage requestMessage) { return(MatchScores.ToScore(Methods.Contains(requestMessage.Method))); }
public int AddScores(MatchScores _match) { int AddedScores = 0; int matchNo = _match.MatchNo; int homeGoals = _match.HomeScore; int awayGoals = _match.AwayScore; int homeGoalsHT = _match.HalfTimeHomeScore; int awayGoalsHT = _match.HalfTimeAwayScore; try { DateTime start = DateTime.Now; string goalServeMatchID = matchNo.ToString(); try { int mtcno = Convert.ToInt32(goalServeMatchID); var mtc = BetDatabase.Matches.Include(x => x.AwayTeam).Include(x => x.HomeTeam).Where(c => c.ResultStatus == 1).Single(m => m.BetServiceMatchNo == mtcno); if (mtc == null) { } // Match mtc = BetDatabase.Matches.Where(mt => mt.BetServiceMatchNo == mtcno).SingleOrDefault(); try { mtc.HomeScore = homeGoals; mtc.AwayScore = awayGoals; mtc.HalfTimeAwayScore = awayGoalsHT; mtc.HalfTimeHomeScore = homeGoalsHT; mtc.ResultStatus = 2; // BetDatabase.Matches.Attach(mtc); BetDatabase.Entry(mtc).State = EntityState.Modified; BetDatabase.SaveChanges(); AddedScores++; } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } string msg = sb.ToString(); } List <Result> resultList = new List <Result>(); /* Match Results*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 1).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 3).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 2).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Match Result */ /* HaltTime Results*/ if (mtc.HalfTimeHomeScore > mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HalfTimeHomeScore < mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 14).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HalfTimeHomeScore == mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End HalfTime Result */ ///*Start Draw No Bet*/ //if (mtc.HomeScore > mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore < mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore == mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} ///*End Match Result */ /* Start Double Chance*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Double Chance */ /* Start Unders Over*/ /* Full Time Total Goals or Wire or underover*/ int FullTimeTotalGoals = (int)(mtc.HomeScore + mtc.AwayScore); if (FullTimeTotalGoals > 0.5) //over 0.5 { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 33).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 0.5) //under0.5 { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 32).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 5).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 4).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 7).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 6).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 3.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 9).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 3.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 8).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 4.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 11).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 4.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 5.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 35).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 5.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 34).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End FullTime U/O/ * * * /*Start HalfTime Unders Over */ /* 0.5 */ int HalfTimeTotalGoals = (int)(mtc.HalfTimeHomeScore + mtc.HalfTimeAwayScore); if (HalfTimeTotalGoals > 0.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 16).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 0.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 15).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /* 0.5*/ /*1.5*/ if (HalfTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 18).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 17).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /*1.5*/ /*2.5 */ if (HalfTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 20).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 19).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /* HT2.5*/ /* End 2.5*/ /*End Half Time Unders/Overs * /* Both Teams To Score*/ if ((homeGoals > 0) && (awayGoals > 0)) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 26).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } else if ((homeGoals == 0) && (awayGoals == 0)) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 27).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End unders Both Teams To Score*/ foreach (Result score in resultList) { List <Bet> betted = new List <Bet>(); betted = BetDatabase.Bets.Include(f => f.Receipt).Where(s => s.MatchId == score.MatchId).Where(j => j.BetOption.BetCategoryId == score.CategoryId).Where(r => r.GameBetStatus == 0).ToList(); foreach (Bet bm in betted) { Receipt rec = BetDatabase.Receipts.Where(rc => rc.ReceiptId == bm.RecieptId).Where(rc => rc.ReceiptStatus == 1).SingleOrDefault(); if (rec == null) { continue; } rec.SubmitedSize = rec.SubmitedSize + 1; if ((bm.BetOptionId == score.OptionId) && (bm.BetOption.BetCategoryId == score.CategoryId)) { rec.WonSize = rec.WonSize + 1; bm.GameBetStatus = 2; } else if ((score.CategoryId == 2) || (score.CategoryId == 4)) { int subCategory = getSubCategory(score.OptionId); int baseCategory = getSubCategory(bm.BetOptionId); if (UnderOverCat(subCategory, baseCategory)) { rec.ReceiptStatus = 2; bm.GameBetStatus = 1; } else { continue; } } else { rec.ReceiptStatus = 2; bm.GameBetStatus = 1; } BetDatabase.Entry(bm).State = EntityState.Modified; // BetDatabase.Entry(bm).Entity = EntityState.Modified; } } BetDatabase.SaveChanges(); List <Receipt> WonReciepts = new List <Receipt>(); WonReciepts = BetDatabase.Receipts.Where(w => w.SetSize == w.WonSize).Where(s => s.ReceiptStatus == 1).ToList(); if (WonReciepts.Count > 0) { foreach (Receipt wonrec in WonReciepts) { wonrec.ReceiptStatus = 3; } BetDatabase.SaveChanges(); } } catch (Exception e) { string msg = e.Message; } } catch (Exception exception) { } return(AddedScores); }
private double IsMatch(IRequestMessage requestMessage) { return(MatchScores.ToScore(Methods.Contains(requestMessage.Method, StringComparer.OrdinalIgnoreCase))); }
/// <summary> /// Tabulates the count of match score categories in which a possible match /// (a dog w/completed profile) has the same match value in a category as the primary dog. /// The higher the match count for a dog, the higher the match quality. Top matches are later /// determined by the dogs with the highest match counts derived from this method. /// </summary> /// <param name="primaryDogScores">Match values of the primary dog</param> /// <param name="dogTrackers"><see cref="List{DogMatchTracker}"/> list of all dogs and their match values</param> /// <returns><see cref="List{DogMatchTracker}"/> list of dogs that includes the total match count for each possible dog match</returns> private List <DogMatchTracker> TabulateMatchCounts(MatchScores primaryDogScores, List <DogMatchTracker> dogTrackers) { foreach (var dog in dogTrackers) { // determine if Weight scores match, add 3 match points for weight // (gives size/weight of dog more weight than other categories) if (dog.Scores.Weight == primaryDogScores.Weight) { dog.MatchCount = dog.MatchCount + 3; } // determine if Playfullness scores match if (dog.Scores.Playfullness == primaryDogScores.Playfullness) { dog.MatchCount = dog.MatchCount + 1; } // determine if Friendliness scores match if (dog.Scores.Friendliness == primaryDogScores.Friendliness) { dog.MatchCount = dog.MatchCount + 1; } // determine if Athletic scores match if (dog.Scores.Athletic == primaryDogScores.Athletic) { dog.MatchCount = dog.MatchCount + 1; } // determine if Training scores match if (dog.Scores.Training == primaryDogScores.Training) { dog.MatchCount = dog.MatchCount + 1; } // determine if Empathy scores match if (dog.Scores.Empathy == primaryDogScores.Empathy) { dog.MatchCount = dog.MatchCount + 1; } // determine if Intelligence scores match if (dog.Scores.Intelligence == primaryDogScores.Intelligence) { dog.MatchCount = dog.MatchCount + 1; } // determine if Aggression scores match if (dog.Scores.Aggression == primaryDogScores.Aggression) { dog.MatchCount = dog.MatchCount + 1; } // determine if Anxiety scores match if (dog.Scores.Anxiety == primaryDogScores.Anxiety) { dog.MatchCount = dog.MatchCount + 1; } // determine if Instinct scores match if (dog.Scores.Instinct == primaryDogScores.Instinct) { dog.MatchCount = dog.MatchCount + 1; } // determine if Confidence scores match if (dog.Scores.Confidence == primaryDogScores.Confidence) { dog.MatchCount = dog.MatchCount + 1; } // determine if Stubbornness scores match if (dog.Scores.Stubbornness == primaryDogScores.Stubbornness) { dog.MatchCount = dog.MatchCount + 1; } // determine if Shedding scores match if (dog.Scores.Shedding == primaryDogScores.Shedding) { dog.MatchCount = dog.MatchCount + 1; } // determine if Smelliness scores match if (dog.Scores.Smelliness == primaryDogScores.Smelliness) { dog.MatchCount = dog.MatchCount + 1; } // determine if dogs are same breed, if so give 5 points (more points than others) if (dog.Scores.Breed == primaryDogScores.Breed) { dog.MatchCount = dog.MatchCount + 5; } } return(dogTrackers); }
public async Task <MatchScores> GetMatchScores(int matchId) { MatchScores result = await Get <MatchScores>($"https://api.swebowl.se/api/v1/matchResult/GetMatchScores?APIKey={apiKey}&matchId={matchId}&matchSchemeId=8M8BA"); return(result); }
private double IsMatch(RequestMessage requestMessage) { // Check if the matcher is a IObjectMatcher if (Matcher is IObjectMatcher objectMatcher) { // If the body is a JSON object, try to match. if (requestMessage.BodyAsJson != null) { return(objectMatcher.IsMatch(requestMessage.BodyAsJson)); } // If the body is a byte array, try to match. if (requestMessage.BodyAsBytes != null) { return(objectMatcher.IsMatch(requestMessage.BodyAsBytes)); } } // Check if the matcher is a IStringMatcher if (Matcher is IStringMatcher stringMatcher) { // If the body is a JSON object, try to use Body (string) to match. if (requestMessage.BodyAsJson != null && requestMessage.Body != null) { return(stringMatcher.IsMatch(requestMessage.Body)); } // If the string body is defined, try to match. if (requestMessage.Body != null) { return(stringMatcher.IsMatch(requestMessage.Body)); } // If the body is a byte array, attempt to convert it and match on that if (requestMessage.BodyAsBytes != null) { try // to convert from the byte[] to a string { var input = Encoding.UTF8.GetString(requestMessage.BodyAsBytes); return(stringMatcher.IsMatch(input)); } catch { // just ignore the exception } } } if (Func != null) { return(MatchScores.ToScore(requestMessage.Body != null && Func(requestMessage.Body))); } if (DataFunc != null) { return(MatchScores.ToScore(requestMessage.BodyAsBytes != null && DataFunc(requestMessage.BodyAsBytes))); } if (JsonFunc != null) { return(MatchScores.ToScore(requestMessage.BodyAsJson != null && JsonFunc(requestMessage.BodyAsJson))); } return(MatchScores.Mismatch); }