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 static void CalculateMatchPoints(this FishingMatch fishingMatch) { List <MatchEntry> sortedMatchEntries = fishingMatch.MatchEntries.OrderByDescending(matchEntry => matchEntry.Weight).ToList(); PositionToPointsMapping positionToPointsMapping = DataFileService.GetDataFile <PositionToPointsMapping>(DataFileType.PositionToPointsMapping) .SingleOrDefault(mapping => mapping.Id == fishingMatch.PositionToPointsMappingId); if (positionToPointsMapping == null) { throw new Exception("Position to points mapping not found"); } for (var index = 0; index < sortedMatchEntries.Count; index++) { sortedMatchEntries[index].Position = index + 1; if (Math.Abs(sortedMatchEntries[index].Weight) <= 0) { sortedMatchEntries[index].Points = positionToPointsMapping.DidNotWeighPoints; continue; } if (index > positionToPointsMapping.PositionToPoints.Count - 1) { sortedMatchEntries[index].Points = positionToPointsMapping.PositionToPoints.Last().Points; continue; } sortedMatchEntries[index].Points = positionToPointsMapping.PositionToPoints[index].Points; } }
private void AddButton(int i, int j) { if (i < this.DataDG.Items.Count) { DataRowView drv = DataDG.Items[i] as DataRowView; DataGridRow row = GetRow(DataDG, i); DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row); DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(j); DGObjectDef objectDef = standard.GetDGObjectDefByName(dataTable.TableName); DataFileService dfs = new DataFileService(objectDef.Code, IDindex[i]); StackPanel _stackpanel = new StackPanel(); _stackpanel.Orientation = Orientation.Horizontal; MyButton _button1 = new MyButton(); _button1.Content = "下载附件"; _button1._dfs = dfs; _button1.Click += _button1._dfs.Downloadfile; MyButton _button2 = new MyButton(); _button2.Content = "上传附件"; _button2._dfs = dfs; _button2.Click += _button2._dfs.Uploadfile; _stackpanel.Children.Add(_button2); _stackpanel.Children.Add(_button1); cell.Content = _stackpanel; } }
public List <string> Get() { IEnumerable <FishingMatch> matches = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches); List <string> seasons = matches.GroupBy(match => match.Season) .Select(group => group.Key) .ToList(); seasons.Insert(0, "All"); return(seasons); }
public IEnumerable <Season> GetSeasons() { IEnumerable <FishingMatch> matches = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches); IEnumerable <Season> seasons = matches.GroupBy(match => new { match.SeasonId, match.Season }) .Select(group => new Season { Id = group.Key.SeasonId, Description = group.Key.Season }); return(seasons); }
public IHttpActionResult GetMatchEntries(int matchId) { FishingMatch fishingMatch = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches) .SingleOrDefault(match => match.Id == matchId); if (fishingMatch == null) { return(NotFound()); } return(Ok(fishingMatch.MatchEntries)); }
public DownloadList(DataFileService parent) { InitializeComponent(); Filelist = new List <Filename>(); _parent = parent; foreach (string st in parent.filenames) { Filename _filename = new Filename(); _filename.Name = st; Filelist.Add(_filename); } DownloadDG.ItemsSource = Filelist; }
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()); }
public List <ChampionshipAnglerDetails> Get([FromUri] int seasonId) { List <FishingMatch> matches = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches) .Where(match => match.SeasonId == seasonId) .ToList(); IEnumerable <string> anglerNames = matches.SelectMany(match => match.MatchEntries) .GroupBy(matchEntry => matchEntry.AnglerName) .Select(group => @group.Key); return((from anglerName in anglerNames let rounds = GetChampionshipRounds(matches, anglerName) select new ChampionshipAnglerDetails { Rounds = rounds, PointsTotal = rounds.Sum(matchEntry => matchEntry.Points), WeightTotal = rounds.Sum(matchEntry => matchEntry.Weight), Name = anglerName, MatchCount = rounds.Count(matchEntry => matchEntry.MatchFished) }).ToList()); }
public IEnumerable <League> Get() { return(DataFileService.GetDataFile <League>(DataFileType.Leagues)); }
public IEnumerable <FishingMatch> Get() { return(DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches)); }
public ImportExportCommands(DataFileService dataFiles) { _dataFiles = dataFiles; }
public ImportExport(DataFileService dataFiles) { _dataFiles = dataFiles; }
public SystemEdit(DataFileService dataFiles, HttpClient client, PrivateChannelService dmCache) { _dataFiles = dataFiles; _client = client; _dmCache = dmCache; }
public IEnumerable <Angler> Get() { return(DataFileService.GetDataFile <Angler>(DataFileType.Anglers)); }