public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "patients")] HttpRequest req , ILogger log) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Environment.GetEnvironmentVariable("AzureWebJobsStorage")); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("PatientTestTable"); ITableDBRepository <Patient> respository = new TableDBRepository <Patient>(); var patientItems = await respository.GetAllPatientInformation(table, "Patient"); return(new OkObjectResult(patientItems)); }
public static async Task <IActionResult> GetPatientAsync( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "patient/{emailId}")] HttpRequest req , ILogger log) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Environment.GetEnvironmentVariable("AzureWebJobsStorage")); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("PatientTestTable"); ITableDBRepository <Patient> respository = new TableDBRepository <Patient>(); var emailId = (req.HttpContext.GetRouteValue("emailId") as string) ?? string.Empty; var patientItems = await respository.GetAPatientInformation(table, "Patient", emailId); if (patientItems is null) { return(new NoContentResult()); } return(new OkObjectResult(patientItems)); }
public static async Task <object> DeleteAPatient( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "patient/delete")] HttpRequestMessage req , ILogger log) { string jsonContent = await req.Content.ReadAsStringAsync(); var patient = JsonConvert.DeserializeObject <Patient>(jsonContent); if (patient is null) { return(new BadRequestResult()); } log.LogInformation($"Patient {patient.Name} for delete request received with email {patient.EmailId} at UTC time {System.DateTime.UtcNow}"); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Environment.GetEnvironmentVariable("AzureWebJobsStorage")); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("PatientTestTable"); ITableDBRepository <Patient> respository = new TableDBRepository <Patient>(); var patientItems = await respository.DeleteAPatientInformation(table, "Patient", patient); return((object)new OkObjectResult(patient)); }