コード例 #1
0
        public async Task <ActionResult> DeleteList(long listID)
        {
            var success = await _service.DeleteList(listID, getID());

            if (success)
            {
                return(Ok());
            }
            return(BadRequest());
        }
コード例 #2
0
ファイル: ListController.cs プロジェクト: kobrynsky/pgskanban
        public IActionResult DeleteList(int id)
        {
            var result = _listService.DeleteList(id);

            if (!result)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
コード例 #3
0
        public IActionResult DeleteListName(DeleteListDto deleteListDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            bool deleteSuccessful = _listService.DeleteList(deleteListDto);

            if (!deleteSuccessful)
            {
                return(BadRequest());
            }
            return(NoContent());
        }
コード例 #4
0
        public IActionResult DeleteList([FromBody] DeleteListDto deleteListDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var result = _listService.DeleteList(deleteListDto);

            if (!result)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task DeleteList_ShouldCallListRepositoryDelete()
        {
            // Data
            var listModel = new ListModel {
                Name = "todo list"
            };

            // Setup
            _mockListRepository.Setup(x => x.Delete(listModel.Id, listModel.UserId))
            .Returns(Task.CompletedTask).Verifiable();

            // Test
            var listService = new ListService(_mockListRepository.Object);
            await listService.DeleteList(listModel.Id, listModel.UserId);

            // Analysis
            _mockListRepository.Verify();
        }
コード例 #6
0
        public IActionResult DeleteList(int id, int boardId)
        {
            var deleteListDto = new DeleteListDto {
                BoardId = boardId, ListId = id
            };

            if (deleteListDto.ListId <= 0 && deleteListDto.ListId <= 0)
            {
                return(BadRequest());
            }

            var result = _listService.DeleteList(deleteListDto);

            if (!result)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
コード例 #7
0
 public IActionResult DeleteList([FromRoute] int id, [FromRoute] int userId)
 {
     try
     {
         if (listService.GetList(id) == null)
         {
             throw new Exception("Error. List not found");
         }
         else
         {
             listService.DeleteList(id);
             var l = listService.GetLists(userId);
             return(Ok(l));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #8
0
ファイル: ListService.cs プロジェクト: allownulls/Todo
        public async Task General()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "TodoDB")
                          .Options;

            using (var db = new ApplicationDbContext(options))
            {
                var listService = new ListService(db);

                var userId        = Guid.NewGuid().ToString();
                var anotherUserId = Guid.NewGuid().ToString();

                string Name1 = "Testname";
                string Name2 = "Testname2";

                var model = new ListModel()
                {
                    OwnerId = userId,
                    Name    = Name1
                };

                await listService.AddList(model);

                var lists = await listService.GetLists(anotherUserId);

                Assert.AreEqual(lists.Count(), 0);

                lists = await listService.GetLists(userId);

                Assert.AreEqual(lists.Count(), 1);

                model.Name = Name2;
                await listService.AddList(model);

                lists = await listService.GetLists(anotherUserId);

                Assert.AreEqual(lists.Count(), 0);

                lists = await listService.GetLists(userId);

                Assert.AreEqual(lists.Count(), 2);

                var list = await listService.GetList(lists.First().Id);

                Assert.IsTrue(list != null);

                await listService.DeleteList(lists.First().Id);

                lists = await listService.GetLists(anotherUserId);

                Assert.AreEqual(lists.Count(), 0);

                lists = await listService.GetLists(userId);

                Assert.AreEqual(lists.Count(), 1);

                await listService.DeleteList(lists.First().Id);

                lists = await listService.GetLists(anotherUserId);

                Assert.AreEqual(lists.Count(), 0);

                lists = await listService.GetLists(userId);

                Assert.AreEqual(lists.Count(), 0);
            }
        }