Esempio n. 1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            [Table("LunchMenu")] CloudTable cloudTable,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string day = req.Query["day"];

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            day = day ?? data?.day;

            return(day != null
                ? (ActionResult) new OkObjectResult(await AzureStorageHelper.GetLunchMenuAsync(cloudTable, day))
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body"));
        }
Esempio n. 2
0
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                var item = await AzureStorageHelper.GetLunchMenuAsync(days[i]);

                switch (i)
                {
                case 0:
                    this.MainMonTbx.Text = item.Main;
                    this.SideMonTbx.Text = item.Side;
                    this.CalMonTbx.Text  = item.Calories.ToString();
                    break;

                case 1:
                    this.MainTuesTbx.Text = item.Main;
                    this.SideTuesTbx.Text = item.Side;
                    this.CalTuesTbx.Text  = item.Calories.ToString();
                    break;

                case 2:
                    this.MainWedTbx.Text = item.Main;
                    this.SideWedTbx.Text = item.Side;
                    this.CalWedTbx.Text  = item.Calories.ToString();
                    break;

                case 3:
                    this.MainThurTbx.Text = item.Main;
                    this.SideThurTbx.Text = item.Side;
                    this.CalThurTbx.Text  = item.Calories.ToString();
                    break;

                case 4:
                    this.MainFriTbx.Text = item.Main;
                    this.SideFriTbx.Text = item.Side;
                    this.CalFriTbx.Text  = item.Calories.ToString();
                    break;
                }
            }
        }