Esempio n. 1
0
        public async Task <bool> DeleteVendorById(int id)
        {
            bool deleted = false;

            using TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

            var deleteVendor = await _repository.DeleteById(id);

            if (deleteVendor != null)
            {
                deleted = true;
            }

            var vendorDeleteDTO = new VendorUpdateDTO
            {
                Id    = deleteVendor.Id,
                Name  = deleteVendor.Name,
                Title = deleteVendor.Title,
                Date  = deleteVendor.Date
            };
            string json = JsonConvert.SerializeObject(vendorDeleteDTO);

            var history = new History()
            {
                VendorId   = vendorDeleteDTO.Id,
                Operation  = "Delete",
                JsonResult = json,
            };

            await _historyRepository.Insert(history);

            scope.Complete();
            return(deleted);
        }
Esempio n. 2
0
        public bool Delete(int id)
        {
            bool result = false;

            var deleteVendor = _repository.DeleteById(id);

            if (deleteVendor > 0)
            {
                result = true;
            }

            return(result);
        }