public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = null)] HttpRequest req, ExecutionContext executionContext) { try { string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); if (string.IsNullOrEmpty(requestBody)) { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(new RequestBodyEmptyException()))); } Story data = JsonConvert.DeserializeObject <Story>(requestBody); Story results = StoryRepository.CreateNew(executionContext, "StoryUpdate").AddOrUpdate(data); if (results == null || results.PrimaryKey == 0) { return((ActionResult) new OkObjectResult(new InsertRecordException(data.Title))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(results))); } } catch (Exception e) { return((ActionResult) new BadRequestObjectResult(new UpdateRecordException(typeof(Scene).Name))); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ExecutionContext executionContext) { IEnumerable <Story> results = StoryRepository.CreateNew(executionContext, "StoryList").GetAll(); if (results == null || results.Count() == 0) { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(new ErrorReadingDataFile(typeof(Story).Name)))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(results))); } }