public IHttpActionResult GetTracks([FromUri] int[] ids = null) { try { logger.Info($"Get Tracks request || ids: [{string.Join(",", ids)}]"); var path = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Tracks.xml"); var locations = new LocationCollection(path); var tracks = locations.GetTrackList(); if (ids != null && ids.Count() > 0) { tracks = tracks.Where(x => ids.Contains(x.TrackId)); } logger.Info($"Get Tracks request || send data: [{tracks.Count()}] Tracks"); return(Ok(tracks)); } catch (Exception e) { logger.Error("Error in GetTracks", e); throw; } }
public IHttpActionResult Get(int id) { try { logger.Info($"Get Tracks request || id: {id}"); var path = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Tracks.xml"); var locations = new LocationCollection(path); var tracks = locations.GetTrackList(); if (id != 0) { tracks = tracks.Where(x => x.TrackId == id); } logger.Info($"Get Tracks request || send data: [{tracks.Count()}] Tracks"); return(Ok(tracks)); } catch (Exception e) { logger.Error("Error in GetTracks", e); throw; } }