コード例 #1
0
        public void Delete_ValidId_DeletedTodoItem()
        {
            //Arrange
            var id = TestHelper.TodoItems.ElementAt(2).Id;

            //Act
            var data = _todoItemService.Delete(id);

            //Assert
            Assert.Equal(id, data.Id);
            Assert.True(data.IsDeleted);
        }
コード例 #2
0
        public async Task WillDeleteOneItem()
        {
            // Arrange
            var key  = Guid.NewGuid().ToString();
            var item = new TodoItem
            {
                Name       = "test",
                IsComplete = true,
            };

            var addedItem = item;

            addedItem.Key = key;

            todoItemRepository.Create(item).Returns(addedItem);

            todoItemRepository.GetAll().Returns(new List <TodoItem>());

            // Act
            await sut.Delete(item);

            var items = await sut.GetAll();

            // Assert
            Assert.IsFalse(items.Any(x => x.Key == item.Key));
        }
コード例 #3
0
        public async Task <ActionResult <TodoItem> > DeleteTodoItem(long id)
        {
            var todoItem = await _todoItemService.Delete(id);

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

            return(todoItem);
        }
コード例 #4
0
ファイル: TodosController.cs プロジェクト: bodorkost/ToDo-App
        public IActionResult Delete(Guid id)
        {
            var removeItem = _todoItemService.Delete(id);

            if (removeItem == null)
            {
                return(BadRequest("Item does not exist in list."));
            }

            return(Ok("Item successfully removed from list."));
        }
コード例 #5
0
        public async Task <IBaseCommandResult> HandleDelete(long id)
        {
            var todoItem = await _todoItemService.Delete(id);

            if (todoItem == null)
            {
                return(new BaseCommandResult(false, "TodoItem not found", null));
            }
            else
            {
                return(new BaseCommandResult(true, "TodoItem deleted with Success!", ItemToDto(todoItem)));
            }
        }
コード例 #6
0
        public async Task <IActionResult> RemoveTodoItem(Guid id)
        {
            var entity = await _service.GetById(id);

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

            if (!await _service.Delete(entity.Id))
            {
                throw new ApiException($"Removal of todo item {id} failed on save.");
            }

            return(NoContent());
        }
コード例 #7
0
        public void Handle(DeleteTodoItemCommand command)
        {
            var todoItem = _todoItemService.Read(x => x.Id == command.Id).FirstOrDefault();

            if (todoItem == null)
            {
                throw new NotFoundException("Objeto não encontrado.", null);
            }

            if (command.Invalid)
            {
                return;
            }

            _todoItemService.Delete((long)command.Id);
        }
コード例 #8
0
        async Task ExecuteDeleteTodoItemCommand(TodoItem item)
        {
            try
            {
                await todoItemService.Delete(item);

                TodoItems.Remove(item);

                // TODO: Remove hardcoded
                MessagingCenter.Send(this, "DeletedTodoItem", item);
            }
            catch (Exception e)
            {
                // TODO: Add alert
                Debug.WriteLine(e.Message);
            }
        }
コード例 #9
0
        public IActionResult Delete(int Id)
        {
            if (Id == default(int))
            {
                return(NotFound());
            }

            var todoItem = _todoItemService.GetById(Id);

            if (todoItem == default(TodoItem))
            {
                return(NotFound());
            }

            _todoItemService.Delete(todoItem);

            return(RedirectToAction("Index"));
        }
コード例 #10
0
        protected virtual async Task <IActionResult> DoDelete(string slug)
        {
            var user = await this.GetLocalUser(UserService);

            var todoItem = await TodoItemService.TodoItemRepository
                           .FindOneBy(t => t.User.Id == user.Id && t.Slug == slug);

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

            await TodoItemService.Delete(todoItem);

            var responseBody = new
            {
                Message = StatusMessageLocalizer["TodoItemDeleted"].Value
            };

            return(Ok(responseBody));
        }
コード例 #11
0
        public IActionResult Delete(int Id)
        {
            if (Id == default(int))
            {
                return(NotFound());
            }

            var todoItem = _todoItemService.GetById(Id);

            if (todoItem == default(TodoItem))
            {
                return(NotFound());
            }

            try {
                _todoItemService.Delete(todoItem);
                return(Ok());
            }
            catch {
            }

            return(BadRequest());
        }
コード例 #12
0
 public void Delete(int id)
 {
     service.Delete(id);
 }
コード例 #13
0
        public async Task <IActionResult> Delete(int id)
        {
            await _todoItemService.Delete(id, User);

            return(RedirectToAction("Index"));
        }
コード例 #14
0
 public ActionResult Delete(int id, int categoryId)
 {
     _itemService.Delete(id);
     return(RedirectToAction("Details", "TodoCategory", new { id = categoryId }));
 }
コード例 #15
0
 public async Task Delete(int id)
 {
     await _todoItemService.Delete(id);
 }
コード例 #16
0
        public IActionResult Delete(string id)
        {
            _itemService.Delete(id);

            return(NoContent());
        }