Beispiel #1
0
        public async Task <ApiResultModel <dynamic> > Delete(Guid id)
        {
            try
            {
                await _transactionServices.Delete(id);

                return(new ApiResultModel <dynamic>()
                {
                    Data = 1,
                    Success = true,
                    Message = "Success",
                    Code = 200
                });
            }
            catch (Exception ex)
            {
                return(new ApiResultModel <dynamic>()
                {
                    Data = -1,
                    Success = false,
                    Message = ex.Message,
                    Code = ex.HResult
                });
            }
        }
Beispiel #2
0
        public void ShouldDeleteTransaction()
        {
            // Arrange
            var faker             = new Faker();
            var csvPath           = faker.Random.String2(2);
            var expectedReference = "ref2";

            _transactionServices.LoadTransactions(csvPath);

            // Act
            _transactionServices.Delete(expectedReference);
            var deletedTransaction = _transactionServices.GetTransaction(expectedReference);

            // Assert
            Assert.Null(deletedTransaction);
        }
        public ActionResult DeleteWithoutRollBack(int id)
        {
            ITransactionServices       transactionService = ServiceFactory.GetTransactionServices();
            ITransactionDetailServices detailService      = ServiceFactory.GetTransactionDetailServices();

            Transaction t = transactionService.Get(id);

            if (t.JournalId != 0)
            {
                ServiceFactory.GetJournalServices().Delete(t.JournalId);
            }

            List <TransactionDetail> detail = (List <TransactionDetail>)detailService.GetAll(t.Id);
            List <int> accId = new List <int>();

            foreach (TransactionDetail d in detail)
            {
                accId.Add(d.AccountId);
                detailService.Delete(d.Id);
            }
            transactionService.Delete(t.Id);
            return(View(accId));
        }
        public ActionResult DeletedConfirmed(string reference)
        {
            var transaction = new TransactionViewModel();

            try
            {
                if (string.IsNullOrWhiteSpace(reference))
                {
                    ViewBag.Error = _localizer["EmptyReference"];
                    return(View(transaction));
                }

                _transactionServices.Delete(reference);

                TempData["Success"] = _localizer["SuccessDeleteMessage"].Value;

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(RedirectToAction(nameof(Delete), "Transaction", new { reference }));
            }
        }
        public async Task <IActionResult> Delete(Guid id)
        {
            await _transactionServices.Delete(id);

            return(Redirect("/transactions"));
        }
 public IActionResult Delete(int id)
 {
     return(Ok(_transactionServices.Delete(id)));
 }