public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { bool result = false; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); HouseholdInfo data = JsonConvert.DeserializeObject <HouseholdInfo>(requestBody); try { result = await _mediator.Send(new StoreHouseholdInfoCommand { Info = data }); } catch (ValidationException vex) { } catch (Exception ex) { } log.LogInformation("C# HTTP trigger function processed a request."); return(new OkObjectResult(result)); }
public async Task <HouseholdInfo> GetHouseholdInfoAsync(string userId) { var response = await _client.GetAsync("householdinfo"); var responseDict = JsonConvert.DeserializeObject <Dictionary <string, HouseholdInfo> >(response.Body); HouseholdInfo result = responseDict.SingleOrDefault(x => x.Key == userId).Value; return(result); }
public async Task <bool> SaveHouseholdInfoAsync(HouseholdInfo info) { var response = await _client.PushAsync("householdinfo", info); if (response.StatusCode == HttpStatusCode.OK) { return(true); } return(false); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log) { HouseholdInfo result = null; try { result = await _mediator.Send(new GetHouseholdInfoCommand { UserId = req.Query["userid"] }); } catch (ValidationException vex) { } catch (Exception ex) { } log.LogInformation("C# HTTP trigger function processed a request."); return(new OkObjectResult(result)); }