public IHttpActionResult Post(int matchId, [FromBody] EntryToAdd entryToAdd) { List <FishingMatch> fishingMatches = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches).ToList(); FishingMatch fishingMatch = fishingMatches.SingleOrDefault(match => match.Id == matchId); if (fishingMatch == null) { return(NotFound()); } var matchEntry = new MatchEntry { AnglerName = entryToAdd.AnglerName, AnglerId = entryToAdd.AnglerId, Peg = entryToAdd.Peg, Weight = entryToAdd.Pounds + (entryToAdd.Ounces / OuncesInPound) }; fishingMatch.MatchEntries.Add(matchEntry); fishingMatch.CalculateMatchPoints(); DataFileService.WriteDataFile(DataFileType.Matches, fishingMatches); return(Created(string.Empty, entryToAdd)); }
public IHttpActionResult CalculatePoints(int matchId) { List <FishingMatch> fishingMatches = Get().ToList(); FishingMatch fishingMatch = fishingMatches.SingleOrDefault(match => match.Id == matchId); if (fishingMatch == null) { return(NotFound()); } fishingMatch.CalculateMatchPoints(); DataFileService.WriteDataFile(DataFileType.Matches, fishingMatches); return(Ok()); }