Exemplo n.º 1
0
 public Brine(Turkey turkey)
 {
     Turkey              = turkey;
     Salt                = 0.05 * Turkey.Weight;
     Water               = 0.66 * Turkey.Weight;
     BrownSugar          = 0.13 * Turkey.Weight;
     Shallots            = 0.2 * Turkey.Weight;
     ClovesOfGarlic      = 0.4 * Turkey.Weight;
     WholePeppercorns    = 0.13 * Turkey.Weight;
     DriedJuniperBerries = 0.13 * Turkey.Weight;
     FreshRosemary       = 0.13 * Turkey.Weight;
     Thyme               = 0.06 * Turkey.Weight;
     BrineTime           = 2.4 * Turkey.Weight;
     RoastTime           = 15 * Turkey.Weight;
 }
Exemplo n.º 2
0
        public static async Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
            HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            string  weight      = req.Query["weight"];
            var     requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            weight ??= data?.weight;
            double lbs;

            try
            {
                lbs = Convert.ToDouble(weight);
                if (weight == null)
                {
                    return(new BadRequestObjectResult(
                               "Please pass a weight on the query string or in the request body"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(new BadRequestObjectResult(
                           "Please pass a weight that is convertible to a double on the query string or in the request body"));
            }

            var turkey = new Turkey()
            {
                Weight = lbs
            };
            var brine = new Brine(turkey);

            return(new OkObjectResult(brine.CreateRecipe()));
        }