Пример #1
0
        protected async void DeleteExpense()
        {
            await ExpenseService.DeleteExpense(Expense.ExpenseId);

            ShowDialog = false;
            NavigationManager.NavigateTo("/expensesoverview");
        }
Пример #2
0
        public void Can_Delete_Saved_Expense()
        {
            var service      = new ExpenseService(_mockExpenseRepo.Object);
            var savedExpense = _sampleExpenses[0];

            service.DeleteExpense(savedExpense.Id);
            _mockExpenseRepo.Verify(x => x.Delete(It.Is <int>(input =>
                                                              input == savedExpense.Id
                                                              )));
        }
        public void UnitOfWork_ShouldCallCommitOnce_WhenDeleteExpenseIsCalled()
        {
            // Arrange
            this.expenseRepoMock.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(new Expense("_", new Guid(), "_", new Guid(), 1M, DateTime.Now, DateTime.Now));
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            expenseService.DeleteExpense(new Guid(), false);

            // Assert
            this.unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
        }
Пример #4
0
        private async Task DeleteExpenseAsync(Expense expense)
        {
            if (await Js.InvokeAsync <bool>("confirm",
                                            "Are you sure you want to delete this expense? " +
                                            "This action cannot be undone."))
            {
                await ExpenseService.DeleteExpense(expense.Id);

                ToastService.ShowSuccess($"The '{ expense.Name }' expense has been sucessfully deleted.", "Expense Deleted");

                Expenses.Remove(expense);
            }
        }
Пример #5
0
        public AjaxResponse DeleteUserExpense(int?expenseId)
        {
            var ajaxResponse = new AjaxResponse();

            try
            {
                _expenseService.DeleteExpense(expenseId);

                ajaxResponse.IsSuccess = true;
            }
            catch (Exception ex)
            {
                ajaxResponse.Data = new
                {
                    Message = ex.Message
                };
            }

            return(ajaxResponse);
        }
Пример #6
0
        public void DeleteExpenseById_Success_Test()
        {
            // Arrange
            int id = 1;

            // create mock for repository
            var mock = new Mock <IExpenseRepository>();

            mock.Setup(s => s.DeleteExpense(Moq.It.IsAny <int>())).Verifiable();

            // service
            ExpenseService expenseService = new ExpenseService();

            ExpenseService.Repository = mock.Object;

            // Act
            expenseService.DeleteExpense(id);

            // Assert
            Assert.IsTrue(true);
        }
Пример #7
0
        public void DeleteExpense_Success_Test()
        {
            // Arrange
            ExpenseDTO dto = SampleExpenseDTO(1);

            dto.IsDeleted = false;

            // create mock for repository
            var mock = new Mock <IExpenseRepository>();

            mock.Setup(s => s.DeleteExpense(Moq.It.IsAny <R_Expense>())).Verifiable();

            // service
            ExpenseService expenseService = new ExpenseService();

            ExpenseService.Repository = mock.Object;

            // Act
            expenseService.DeleteExpense(dto);

            // Assert
            Assert.IsTrue(true);
        }
Пример #8
0
        private async void ConfirmDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            // Disable the button to prevent multiple presses
            ConfirmDeleteButton.IsEnabled = false;

            // Display the progress wheel when getting data
            ProgressRing LoginProgress = new ProgressRing();

            LoginProgress.HorizontalAlignment = HorizontalAlignment.Center;
            LoginProgress.VerticalAlignment   = VerticalAlignment.Center;
            ContentRoot.Children.Add(LoginProgress);
            LoginProgress.IsActive = true;

            if (await ExpenseService.DeleteExpense(Expense))
            {
                navigationHelper.GoBack();
            }
            // Disable the progress wheel
            LoginProgress.IsActive = false;
            ContentRoot.Children.Remove(LoginProgress);

            // Reenable the button after finished
            ConfirmDeleteButton.IsEnabled = true;
        }
 public IActionResult Delete(int ItemId)
 {
     _ES.DeleteExpense(ItemId);
     return(RedirectToAction("Index"));
 }
Пример #10
0
        public IActionResult Delete(int id)
        {
            _service.DeleteExpense(id);

            return(new NoContentResult());
        }