public static async Task <IActionResult> UpdateCheck([HttpTrigger(AuthorizationLevel.Function, "put", Route = "maintenance/{id}")] HttpRequest req, string id, ILogger log) { log.LogInformation($"Update existing engineer request"); try { string _RequestBody = await new StreamReader(req.Body).ReadToEndAsync(); MaintenanceCheckEntity _Entity = JsonConvert.DeserializeObject <MaintenanceCheckEntity>(_RequestBody); if (await ChecksRepo.Get(id) != null) { await ChecksRepo.Update(id, _Entity); } else { return(new NotFoundResult()); } } catch (Exception _Exception) { log.LogError(_Exception.Message); return(new NotFoundResult()); } return(new OkResult()); }
public static async Task <IActionResult> GetSingleCheck([HttpTrigger(AuthorizationLevel.Function, "get", Route = "maintenance/{id}/")] HttpRequest req, string id, ILogger log) { log.LogInformation($"GET single check {id}"); MaintenanceCheckEntity _Result = null; try { _Result = await ChecksRepo.Get(id); } catch (Exception _Exception) { log.LogError(_Exception.Message); } if (_Result == null) { return(new NotFoundResult()); } return(new JsonResult(_Result)); }
public static async Task <IActionResult> RemoveCheck([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "maintenance/{id}")] HttpRequest req, string id, ILogger log) { log.LogInformation($"Remove check request"); try { if (await ChecksRepo.Get(id) != null) { await ChecksRepo.Remove(id); } else { return(new NotFoundResult()); } } catch (Exception _Exception) { log.LogError(_Exception.Message); return(new NotFoundResult()); } return(new OkResult()); }