Esempio n. 1
0
        public async Task <IActionResult> DeleteAsync(long id)
        {
            try
            {
                var deleted = await toDoTaskService.DeleteAsync(id).ConfigureAwait(false);

                return(Ok(deleted));
            }
            catch (Exception)
            {
                return(BadRequest("Error occured at deleting data."));
            }
        }
Esempio n. 2
0
        public async Task DeleteAsync_Should_DeleteEntityLogically()
        {
            // Arrange
            var entity = Builder <ToDoTask> .CreateNew()
                         .With(x => x.Id        = 1)
                         .With(x => x.IsDeleted = false)
                         .Build();

            todoTaskRepositoryMock.Setup(mock => mock.GetByIdAsync(1))
            .ReturnsAsync(entity);

            todoTaskRepositoryMock.Setup(mock => mock.UpdateAsync(entity))
            .ReturnsAsync(entity);

            // Act
            var result = await toDoTaskService.DeleteAsync(1).ConfigureAwait(false);

            // Assert
            Assert.NotNull(result);
            Assert.True(entity.IsDeleted);
        }
        public async Task Delete(int id)
        {
            ToDoTask model = await _toDoTaskService.GetByIdAsync(id);

            await _toDoTaskService.DeleteAsync(model);
        }