Ejemplo n.º 1
0
        public async void Return_DrugPackageBarcode()
        {
            const string barcode = "3400931923077";

            var result = await _directory.Search(barcode);

            Assert.Contains(barcode, result);
        }
Ejemplo n.º 2
0
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "directory/{countryCode}/barcode/{code}")] HttpRequest req, string code,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            const string path = "./Data/french-directory/fic_cis_cip/";
            //todo use strategy pattern to determine which directory to use depending on country code

            var baseDirectory        = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var rootDirectory        = Path.GetFullPath(Path.Combine(baseDirectory, ".."));
            var frenchDrugRepository = new FrenchDrugRepository(rootDirectory, path);
            var directory            = new FrenchDrugDirectory(frenchDrugRepository, new FrenchLeafletRepository(new HttpClient()));

            //todo add to readme why the url is like that
            var result = await directory.Search(code);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(result, Encoding.UTF8, "application/json")
            });
        }