public async Task <IActionResult> UpdateFallOfWicket([FromForm] TeamMatchScoredto model) { if (ModelState.IsValid) { foreach (var fallOfWicket in model.FallOfWicket) { var fallOfWicketDbModel = new FallOfWicket { FallOfWicketId = fallOfWicket.FallOfWicketId }; _context.FallOFWickets.Attach(fallOfWicketDbModel); fallOfWicketDbModel.FallOfWicketId = fallOfWicket.FallOfWicketId; fallOfWicketDbModel.First = fallOfWicket.First; fallOfWicketDbModel.Second = fallOfWicket.Second; fallOfWicketDbModel.Third = fallOfWicket.Third; fallOfWicketDbModel.Fourth = fallOfWicket.Fourth; fallOfWicketDbModel.Fifth = fallOfWicket.Fifth; fallOfWicketDbModel.Sixth = fallOfWicket.Sixth; fallOfWicketDbModel.Seventh = fallOfWicket.Seventh; fallOfWicketDbModel.Eight = fallOfWicket.Eight; fallOfWicketDbModel.Ninth = fallOfWicket.Ninth; fallOfWicketDbModel.Tenth = fallOfWicket.Tenth; fallOfWicketDbModel.TeamId = fallOfWicket.TeamId; fallOfWicketDbModel.MatchId = fallOfWicket.MatchId; _context.FallOFWickets.Update(fallOfWicketDbModel); } await _context.SaveChangesAsync(); return(Json(ResponseHelper.UpdateSuccess())); } else { return(Json(ResponseHelper.UpdateUnSuccess())); } }
private static void ProcessFallOfWickets(HtmlNode row, Innings innings) { List <FallOfWicket> fallOfWickets = new List <FallOfWicket>(); // If we ever decide to add support for who the wicket was... MatchCollection matches = Regex.Matches(row.FirstChild.InnerHtml, @"(?'wicket'\d{1,2})-(?'runs'(?:\?|\d{1,3}))(?:\s\(<a\shref=""/Archive/Players/\d+/\d+/(?'player'\d+).html"">[^<]+</a>,\s(?'overs'\d+\.?\d?)\sov\))?"); //MatchCollection matches = Regex.Matches(content, @"(?'wicket'\d{1,2})-(?'runs'(?:\?|\d{1,3}))"); foreach (Match fall in matches) { int wicket = int.Parse(fall.Groups["wicket"].Value); int?runs = null; if (fall.Groups["runs"].Value != "?") { runs = int.Parse(fall.Groups["runs"].Value); } string overs = fall.Groups["overs"].Value; string player = fall.Groups["player"].Value; FallOfWicket fow = new FallOfWicket { Wicket = wicket, Runs = runs, Overs = overs }; if (!string.IsNullOrEmpty(player)) { fow.OutBatsmanId = PlayerDetails.GenerateId(int.Parse(player)); } fallOfWickets.Insert(wicket - 1, fow); } innings.FallOfWickets = fallOfWickets; }