Guid IMedicineBatchRepository.CreateAndReturnId(MedicineBatch medicineBatch) { (this as IMedicineBatchRepository).Create(medicineBatch); return(medicineBatch.Id); }
void IMedicineBatchRepository.Update(MedicineBatch medicineBatch) { dbContext.MedicineBatches.Update(medicineBatch); dbContext.SaveChanges(); }
void IMedicineBatchBackgroundJob.WaitForTransactionToSuccessThenFinishCreatingMedicineBatch(MedicineBatch medicineBatch) { bool isTransactionSuccess = false; do { var receipt = ethereumService.GetTransactionReceipt(medicineBatch.TransactionHash).Result; if (receipt == null) { continue; } if (receipt.Status.Value == (new HexBigInteger(1)).Value) { isTransactionSuccess = true; var contractAddress = ethereumService.GetObjectContractAddress(medicineBatch.Id).Result; medicineBatch.ContractAddress = contractAddress; medicineBatch.TransactionStatus = Models.Database.TransactionStatuses.Success; medicineBatchRepository.Update(medicineBatch); var medicineBatchContract = ethereumService.GetContract(MedicineBatchAbi, medicineBatch.ContractAddress); var updateFunction = ethereumService.GetFunction(medicineBatchContract, EthereumFunctions.UpdateMedicineBatchInformation); var updateReceipt = updateFunction.SendTransactionAndWaitForReceiptAsync( ethereumService.GetEthereumAccount(), new HexBigInteger(6000000), new HexBigInteger(Nethereum.Web3.Web3.Convert.ToWei(50, UnitConversion.EthUnit.Gwei)), new HexBigInteger(0), functionInput: new object[] { medicineBatch.MedicineId.ToString(), medicineBatch.BatchNumber, medicineBatch.ManufacturerId.ToString(), medicineBatch.Quantity, medicineBatch.Unit, medicineBatch.ManufactureDate.ToUnixTimestamp(), medicineBatch.ExpiryDate.ToUnixTimestamp() }).Result; } }while (isTransactionSuccess != true); }