public async Task <IActionResult> DeleteCategory(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }
            await _expenseRepository.DeleteExpense(id);

            return(NoContent());
        }
        public IActionResult DeleteConfirmed(int Id)
        {
            var expense = _expenseRepository.GetExpense(Id);

            _expenseRepository.DeleteExpense(expense);

            Accountancy accountancy = new Accountancy();

            _accountancyRepository.CreateOrEditExpense(accountancy);

            return(RedirectToAction(nameof(Index)));
        }
Example #3
0
        public async Task <string> DeleteExpense(int id)
        {
            try
            {
                var res = await _repository.DeleteExpense(id);

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        public void DeleteExpense(ExpenseDTO dto)
        {
            try
            {
                log.Debug(ExpenseDTO.FormatExpenseDTO(dto));

                R_Expense t = ExpenseDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteExpense(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Example #5
0
        public IActionResult DeleteExpense(int id)
        {
            var isDeleted = _expenseRepository.DeleteExpense(id);

            if (isDeleted)
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(304));
            }
        }
Example #6
0
        public IActionResult DeleteExpense(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            var expenseToDelete = _expenseRepository.GetExpenseById(id);

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

            _expenseRepository.DeleteExpense(id);

            return(NoContent());//success
        }
        public async Task <Result> DeleteExpense(int expenseId, string userId)
        {
            var expense = await _expenseRepository.GetExpense(expenseId);

            if (expense == null)
            {
                return(Result.Failure());
            }

            var hasUserPermission = await _walletPermissionService.HasUserAccess(expense.WalletId, userId);

            if (!hasUserPermission)
            {
                return(Result <BaseExpenseDto> .Failure());
            }

            _expenseRepository.DeleteExpense(expense);
            return(Result.Success());
        }
        public async Task DeleteExpense_GivenExpense_ExpenseDeletedAsync()
        {
            var expectedExpenseToDelete = new Expense()
            {
                Id          = new Guid("7c29c6bc-7b3c-42cc-8e6c-94ec609882b7"),
                Title       = "TestExpense_5",
                ExpenseDate = new DateTime(2020, 9, 1, 0, 0, 0, 0),
                Cost        = 5960,
                Category    = "TestCategory_3",
                UserId      = new Guid("5db0a816-659c-4ec4-af75-c5b0ce558b46")
            };

            await _expenseRepository.DeleteExpense(expectedExpenseToDelete);

            var expenses = await _expenseRepository
                           .GetUserExpenses(new Guid("5db0a816-659c-4ec4-af75-c5b0ce558b46"),
                                            new ExpensesResourceParameters());

            Assert.IsTrue(expenses.Count() == 1);
        }
        public async Task <IActionResult> DeleteExpense([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorModel <Object>(ProjectCodes.Form_Generic_Error)));
            }

            Console.WriteLine("[ExpenseControlelr][Delete Expense]" + id);

            try {
                if (await _expenseRepository.GetExpense(id) == null)
                {
                    return(NotFound("Expense Not Found"));
                }

                await _expenseRepository.DeleteExpense(id);

                return(Ok());
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(BadRequest(new ErrorModel <Object>(ProjectCodes.Generic_Error)));
            }
        }
        public async Task <IActionResult> Delete(int Id)
        {
            try
            {
                var Expense = await _repository.GetExpenseAsync(Id);

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

                if (await _repository.DeleteExpense(Expense))
                {
                    return(Ok());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }

            return(BadRequest("Failed to delete the Expense"));
        }
Example #11
0
 public async Task DeleteExpense(int expenseId)
 {
     await _expenseRepository.DeleteExpense(expenseId);
 }
Example #12
0
 public void DeleteExpense(int expenseId)
 {
     _expenseRepo.DeleteExpense(expenseId);
 }
Example #13
0
        public async Task DeleteUserExpenseById(Guid userId, Guid expenseId)
        {
            var expenseToDelete = await this.GetUserExpenseById(userId, expenseId);

            await _repository.DeleteExpense(expenseToDelete);
        }
Example #14
0
 public async Task DeleteExpenseAsync(int expenseId)
 {
     //TODO : Charges should be recalculate
     await _expenseRepository.DeleteExpense(expenseId);
 }
Example #15
0
 public ActionResult DeleteExpense(int id)
 {
     _expenseRepository.DeleteExpense(id);
     return(Ok());
 }