public static async Task <IActionResult> UpdateTask([HttpTrigger(AuthorizationLevel.Function, "put", Route = "maintenance/{id}/tasks/{taskID}")] HttpRequest req, string id, string taskID, ILogger log) { log.LogInformation($"Update existing task in check request"); try { string _RequestBody = await new StreamReader(req.Body).ReadToEndAsync(); TaskEntity _Entity = JsonConvert.DeserializeObject <TaskEntity>(_RequestBody); if (await TasksRepo.Get(taskID) != null) { await TasksRepo.Update(taskID, _Entity); } else { return(new NotFoundResult()); } } catch (Exception _Exception) { log.LogError(_Exception.Message); return(new NotFoundResult()); } return(new OkResult()); }
public static async Task <IActionResult> RemoveTask([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "maintenance/{id}/tasks/{taskID}")] HttpRequest req, string id, string taskID, ILogger log) { log.LogInformation($"Remove task in check request"); try { if (await TasksRepo.Get(taskID) != null) { await TasksRepo.Remove(taskID); } else { return(new NotFoundResult()); } } catch (Exception _Exception) { log.LogError(_Exception.Message); return(new NotFoundResult()); } return(new OkResult()); }