Beispiel #1
0
        public async Task <IActionResult> DeleteMedicine([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var medicine = await _medicineRepository.FindAsync(id);

            if (medicine == null)
            {
                return(NotFound());
            }

            _medicineRepository.Delete(medicine);
            await _medicineRepository.SaveChangesAsync();

            return(Ok(medicine));
        }
        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;
            }
        }
Beispiel #3
0
        public bool DeleteMedicine(MedicineDto medicine)
        {
            var entity = _DtoMapper.Map(medicine);

            return(_MedicineRepository.Delete(entity));
        }
Beispiel #4
0
 public bool DeleteMedicine(int medicineId)
 {
     return(_medicineRepository.Delete(medicineId));
 }
Beispiel #5
0
        public void DeleteMedicine(long id)
        {
            var Medicine = _repo.Find(id);

            _repo.Delete(Medicine);
        }
Beispiel #6
0
        public async Task <bool> Delete(int id)
        {
            var success = await _repository.Delete(id);

            return(success);
        }
        public void Delete(Medicine medicine)
        {
            DeleteFilesForGivenId(medicine.Id);

            _repository.Delete(medicine);
        }
Beispiel #8
0
 public void Delete(int idSelected)
 {
     _repository.Delete(idSelected);
 }
Beispiel #9
0
        public bool DeleteMedicine(MedicineDTO medicine)
        {
            var entity = _DTOMappers.Map(medicine);

            return(_medicineRepository.Delete(entity));
        }
Beispiel #10
0
 private void Med_Delete_Product_Click(object sender, EventArgs e)
 {
     medRepos.Delete((int)dataGridView1.CurrentCell.Value);
     Clear_Table(this.dataGridView1);
     Load_Med_Table(this.dataGridView1);
 }