public ActionResult About() { ViewBag.Message = "Your application description page."; this.ViewData["Greeting"] = greetingService.SayHello(); return(View()); }
public string GetGreeting() { IGreetingService service1 = greetingFactory.Create(GreetingType.EMILY); IGreetingService service2 = greetingFactory.Create(GreetingType.JOHN); IGreetingService service3 = greetingFactory.Create(GreetingType.JOSHUA); StringBuilder sb = new StringBuilder(); sb.Append(service1.SayHello() + "\n"); sb.Append(service2.SayHello() + "\n"); sb.Append(service3.SayHello()); return(sb.ToString()); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); name = name ?? data?.name; return(name != null ? (ActionResult) new OkObjectResult(_greetingService.SayHello(name)) : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public IActionResult Index() { var content = _greetingService.SayHello(); return(Content(content)); }