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 <Scene>(new RequestBodyEmptyException()))); } Scene data = JsonConvert.DeserializeObject <Scene>(requestBody); Scene results = SceneRepository.CreateNew(executionContext, "SceneUpdate").AddOrUpdate(data); if (results == null) { return((ActionResult) new OkObjectResult(new InsertRecordException(data.Title))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Scene>(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) { Story data = await req.GetFromBody <Story>(); var results = SceneRepository.CreateNew(executionContext, "SceneTitlesList").GetSceneTitlesForStory(data.PrimaryKey); return((ActionResult) new OkObjectResult(new RequestResponse <SceneTitle>(results))); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ExecutionContext executionContext) { Scene data = await req.GetFromBody <Scene>(); Scene Scene = SceneRepository.CreateNew(executionContext, "Scene").GetByPK(data.PrimaryKey); if (Scene == null) { return((ActionResult) new OkObjectResult(new RequestResponse <Scene>(new PrimaryKeyNotFoundException(data.PrimaryKey)))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Scene>(Scene))); } }