Ejemplo n.º 1
0
        public PageAViewModel(IMyService myService)
        {
            message = myService.GetMessage("PageAViewModel");

            UpdateMessageCommand = new DelegateCommand(() =>
            {
                Message += "!";
            });
        }
Ejemplo n.º 2
0
        public HelloModule(IMyService myService)
        {
            this.RequiresAuthentication();
            this.RequiresClaims(new string[] { "admin1" });

            Before += ctx => {
                return (this.Context.CurrentUser == null) ? new HtmlResponse(HttpStatusCode.Unauthorized) : null;
            };

            Get["/Hello"] = parameters =>
            {
                return "Hello " + myService.GetMessage();
            };

            Get["/users"] = parameters =>
            {
                return Response.AsJson(GetAllUsers());
            };
        }
Ejemplo n.º 3
0
        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;

            var response = await _client.GetAsync("https://microsoft.com");

            var message = _service.GetMessage();

            return(name != null
                ? (ActionResult) new OkObjectResult($"Hello, {name}")
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body"));
        }