public IEnumerable <string> GetFarmIdsAuthorized([FromBody] FarmIdRequest request) { var defaultValue = default(KeyValuePair <string, IEnumerable <string> >); //Check if the resource exists. Otherwise return an empty array var resource = _cache.GetResources().FirstOrDefault(u => request.ResourceUrl.Contains(u.Key, StringComparison.OrdinalIgnoreCase)); if (resource.Equals(defaultValue)) { return(new string[0]); } //If all the resources are requested return them all if (request.All) { return(resource.Value); } //Else check what ids are present in both the arrays and return those. If there are none, return an empty array return(resource.Value.Intersect(request.FarmIds)); }
public IEnumerable <string> GetFarmIds([FromBody] FarmIdRequest request) { return(GetFarmIdsAuthorized(request)); }