public async void Run([ServiceBusTrigger("sbq-medicialsupplyorders-out", Connection = "ServiceBusConnection")] string medicineOrderQueueItem , ILogger log) { log.LogInformation($"Received Medicine Order Pharmacy Updates from ServiceBus queue : {medicineOrderQueueItem}"); MedicineOrderPharmacyApproval medicineOrderPharmacyApproval = JsonConvert.DeserializeObject <MedicineOrderPharmacyApproval>(medicineOrderQueueItem); _ = await _medicalSupplyOrderRepository .ModifyOrderWithPharmacyUpdates(_connectionStrings.SqlServerConnectionString, medicineOrderPharmacyApproval) .ConfigureAwait(false); log.LogInformation($"Received Medicine Order Pharmacy Updated Sent to SQL Server: {medicineOrderPharmacyApproval}"); }
public async Task <bool> ModifyOrderWithPharmacyUpdates(string connectionString, MedicineOrderPharmacyApproval medicineOrderPharmacyApproval) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand() { CommandText = "[dbo].[usp_update_med_order_with_pharmacy_updates]", Connection = connection, CommandType = CommandType.StoredProcedure }; command.Parameters.AddWithValue("@Id", medicineOrderPharmacyApproval.Id).SqlDbType = SqlDbType.UniqueIdentifier; command.Parameters.AddWithValue("@PharmacyOrderStatus", medicineOrderPharmacyApproval.PharmacyOrderStatus).SqlDbType = SqlDbType.VarChar; command.Parameters.AddWithValue("@PharmacyTimeofApproval", medicineOrderPharmacyApproval.PharmacyTimeofApproval).SqlDbType = SqlDbType.DateTime2; command.Parameters.AddWithValue("@PharmacyAdditionalComments", medicineOrderPharmacyApproval.PharmacyAdditionalComments).SqlDbType = SqlDbType.VarChar; connection.Open(); await command.ExecuteNonQueryAsync().ConfigureAwait(false); } return(true); }