Exemplo n.º 1
0
        public async Task <string> GetConfiguredContactForService(string service)
        {
            // Get the services configuration, return the configured contact if any
            var serviceConfig = ServicesConfiguration.GetConfiguredServices().Services.FirstOrDefault(i => i.Name == service);

            if (serviceConfig == null)
            {
                return(null);
            }
            return(serviceConfig.Contact);
        }
Exemplo n.º 2
0
        public async Task <IList <CV> > FindCVsForService(string service)
        {
            // Get all offices in Norway
            var offices = await GetOffices("no");

            // Get the service configuration, which maps offices to services
            var officeForService = ServicesConfiguration.GetConfiguredServices().Services.FirstOrDefault(s => s.Name.Equals(service, StringComparison.OrdinalIgnoreCase));

            if (officeForService == null)
            {
                return(new CV[0]);
            }

            var office = offices.FirstOrDefault(o => o.Name == officeForService.Office);

            if (office == null)
            {
                throw new Exception($"Office '{officeForService.Name}' not found in CVPartner.");
            }

            // Office search string
            var officeIdsString = "&office_ids[]=" + office.Id;
            var serviceRole     = ServicesConfiguration.GetPreferredRoles().First();

            var cvs    = new Dictionary <string, CV>();
            var path   = "/api/v3/search?query[0]=" + serviceRole + "&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());
        }