Ejemplo n.º 1
0
        public JsonResult Del(int id)
        {
            ActionResultModel <string> model = new ActionResultModel <string>();

            model.isSuccess   = ls.Delete(id);
            model.respnseInfo = model.isSuccess ? "删除成功" : "删除失败";
            return(Json(model));
        }
        public void Run()
        {
            var now         = DateTime.UtcNow;
            var nowString   = now.ToString("yyyyMMddHHmmss");
            var initialName = "b-" + nowString;
            var updateName  = "a-" + nowString;

            using (var service = new ListService())
            {
                // Create a list
                var afterCreate = service.Create(new CreateListParameters(initialName, initialName, 1));

                // Update the list
                var afterUpdate = service.Update(afterCreate.Id, new UpdateListParameters(updateName, updateName, 1));

                // Get 8 lists, with page size of 3
                var lists = service.GetIndex(3).SetLimit(8).ToList();

                // Get 1 page of lists, size 3
                var listPages = service.GetIndexAsPages(3).SetLimit(1).ToList();

                // Add people to the list
                service.AddPeople(afterCreate.Id, Enumerable.Range(1, 100).ToList());

                // Get the people in the list
                var people = service.GetPeople(afterCreate.Id).ToList();

                // Remove some of the people from the list
                service.RemovePeople(afterCreate.Id, Enumerable.Range(50, 80).ToList());

                // Add a tag to the people in the list
                service.AddTag(afterCreate.Id, "nbc_testtag1");

                // Remove the tag from the people in the list
                service.RemoveTag(afterCreate.Id, "nbc_testtag1");

                // Delete the list
                service.Delete(afterCreate.Id);
            }
        }
Ejemplo n.º 3
0
        public void Delete_removes_a_list_and_nested_cards_via_context()
        {
            var cards       = TestUtils.GetCardData();
            var mockSetCard = TestUtils.InitCardMoqSet(cards);
            var lists       = TestUtils.GetNestedListData(cards);
            var mockSetList = TestUtils.InitListMoqSet(lists);

            var mockContext = new Mock <TrelloDbContext>();

            mockContext.Setup(c => c.tblCard).Returns(mockSetCard.Object);
            mockContext.Setup(c => c.tblList).Returns(mockSetList.Object);

            var service = new ListService(mockContext.Object);

            service.Delete(new List()
            {
                ListId = 1
            });

            mockSetCard.Verify(m => m.Remove(It.IsAny <Card>()), Times.Exactly(3));
            mockSetList.Verify(m => m.Remove(It.IsAny <List>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Ejemplo n.º 4
0
 public IActionResult DeleteContact(ContactList.Contact contactDelete)
 {
     listService.Delete(contactDelete);
     return(RedirectToAction(nameof(DeleteSuccess)));
 }