Ejemplo n.º 1
0
        public async Task DelTodo()
        {
            var fakeUserid = Guid.NewGuid();
            var fakeType   = new TodoType
            {
                Name = "活动"
            };

            fakeType.AddModel(fakeUserid);
            var fakeTodo = new Todo
            {
                Title    = "明日社区活动",
                TodoType = fakeType,
                OffTime  = DateTime.Now
            };

            fakeTodo.AddModel(fakeUserid);
            _inMemoryContext.Add <Todo>(fakeTodo);
            await _inMemoryContext.SaveChangesAsync();

            Assert.Equal(1, await _inMemoryContext.Todos.Where(c => c.Id == fakeTodo.Id).Where(c => c.IsActive == true).CountAsync());
            await _todoService.DelTodoAsync(fakeTodo.Id);

            Assert.Equal(1, await _inMemoryContext.Todos.Where(c => c.Id == fakeTodo.Id).Where(c => c.IsActive == false).CountAsync());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var result = await _todoService.DelTodoAsync(id);

            if (!result)
            {
                return(Redirect("/home/index"));
            }
            return(Redirect("/"));
        }