コード例 #1
0
        public async Task <string> GetConfiguredContactForIndustry(string industry)
        {
            // Get the industry configuration, return the configured contact if any
            var industryConfig = IndustryConfiguration.GetConfiguredIndustries().Industries.FirstOrDefault(i => i.Name == industry);

            if (industryConfig == null)
            {
                return(null);
            }
            return(industryConfig.Contact);
        }
コード例 #2
0
        public async Task <IList <CV> > FindCVsForIndustry(string industry)
        {
            // Get all offices in Norway
            var offices = await GetOffices("no");

            // Get the industry configuration, which contains all the variants of that industry registered in the CVPartner database
            var industryConfig = IndustryConfiguration.GetConfiguredIndustries().Industries.FirstOrDefault(i => i.Name == industry);

            if (industryConfig == null)
            {
                //throw new Exception($"Unknown industry: {industry}.");
                industryConfig = new Models.Configuration.Industry {
                    Name = industry, Variants = new[] { industry }
                };
            }
            // Office search string
            var officeIdsString = offices.Aggregate("", (s, o) => s + "&office_ids[]=" + o.Id); // sic!

            var cvs = new Dictionary <string, CV>();

            foreach (var variant in industryConfig.Variants)
            {
                var path   = "/api/v3/search?query[0]=" + industry + "&filter_fields[0]=" + officeIdsString + "&size=4&from=0";
                var result = await SendRequest(path);

                var consultantsResponse = JsonConvert.DeserializeObject <ConsultantsResponse>(result);
                foreach (var cvWrapper in consultantsResponse.Cvs)
                {
                    var cv = cvWrapper.CV;
                    if (!cvs.ContainsKey(cv.Name))
                    {
                        cvs.Add(cv.Name, cv);
                    }
                }
            }

            return(cvs.Values.ToList());
        }