public async Task <IActionResult> Post(MedicineForAddDTO model) { Medicine medicine = mapper.Map <Medicine>(model); await medicineRepository.Add(medicine).ConfigureAwait(true); await unitOfWork.CompleteAsync().ConfigureAwait(true); return(Ok(mapper.Map <MedicineForGetDTO>(await medicineRepository.Get(medicine.Id).ConfigureAwait(true)))); }
async Task IMedicineService.Delete(Guid id) { var medicine = medicineRepository.Get(id); if (medicine == null) { throw new ArgumentException("Id does not exist in the system.", nameof(id)); } try { var function = ethereumService.GetFunction(EthereumFunctions.RemoveMedicine); var transactionHash = await function.SendTransactionAsync( ethereumService.GetEthereumAccount(), new HexBigInteger(1000000), new HexBigInteger(0), functionInput : new object[] { id.ToString() }); var contract = ethereumService.GetContract(MedicineAbi, medicine.ContractAddress); var deleteFunction = ethereumService.GetFunction(contract, EthereumFunctions.SelfDelete); var receipt = await deleteFunction.SendTransactionAsync( ethereumService.GetEthereumAccount(), new HexBigInteger(6000000), new HexBigInteger(Nethereum.Web3.Web3.Convert.ToWei(5, UnitConversion.EthUnit.Gwei)), new HexBigInteger(0), functionInput : new object[] { } ); medicineRepository.Delete(id); } catch (Exception ex) { throw ex; } }
public Medicine Get(int Id) { var result = _repository.Get(Id); return(result); }