public async System.Threading.Tasks.Task<IHttpActionResult> Get(string animal, string date, string countyID) { using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(string.Format("~/App_Data/animals/{0}.json", animal)))) { Hunting animalobj = await System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<Hunting>(reader.ReadToEnd())); var conversion = new Utils.Converter(); var ids = conversion.CountyToGnis(Convert.ToInt32(countyID)).Select(x => x.FEATURE_ID).ToList(); // var seasons = (from s in animalobj.seasons select s).ToList(); List<ReturnInfo> returnData = new List<ReturnInfo>(); foreach (var ranges in animalobj.seasons) { var localRestrictions = new List<Location>(); foreach (var range in ranges.range) { if (range?.season?.date != null) { if (DateConverter.ConvertToDateTime(date) >= DateConverter.ConvertToDateTime(range.season.date.starts) && DateConverter.ConvertToDateTime(date) <= DateConverter.ConvertToDateTime(range.season.date.ends) ) { var vals = range.places.Values; localRestrictions.AddRange(vals.Select(val => new Location { gnis_id = val.gnis_id, fips_code = val.fips_code, restriction = val.restriction }).Where( x => ids.Contains(TypeConvert.StrToIntDef(x.gnis_id, 0) )) ); if(returnData.Where(x => x.Season.name == ranges.name).FirstOrDefault() == null) returnData.Add(new ReturnInfo(ranges, localRestrictions)); } } } } return Ok(returnData); } }
public IHttpActionResult GnisToCounty(string gnis) { var data = new Utils.Converter().GnisToCounty(Int32.Parse(gnis)); return Ok(data); }
public IHttpActionResult CountyToGnis(string county) { var data = new Utils.Converter().CountyToGnis(Int32.Parse(county)); return Ok(data); }