public async Task <IActionResult> Get() { string userId = _operatorUser.Id; if (string.IsNullOrEmpty(userId)) { return(NotFound()); } var lists = await _toDoShareRepository.GetListsAsync(new Guid(userId)); var result = lists.Select(x => new ToDoListResource { Id = x.List.Id, Title = x.List.Title, UserId = x.List.UserId, Date = x.ShareTime }); return(Ok(result)); }
public async Task GetLists() { await _unitOfWork.SaveAsync(); var listModel = new ToDoList(); var id1 = Guid.NewGuid(); listModel.Id = id1; listModel.CreateTime = DateTime.Now; listModel.Title = "测试一下"; listModel.UserId = Guid.NewGuid(); _toDoListRepository.AddToDoList(listModel); var shareUser = Guid.NewGuid(); var shareId1 = Guid.NewGuid(); var shareModel = new ToDoShare(); shareModel.Id = shareId1; shareModel.ShareTime = DateTime.Now; shareModel.ListId = id1; shareModel.UserId = shareUser; _toDoShareRepository.AddToDoShare(shareModel); var shareId2 = Guid.NewGuid(); shareModel = new ToDoShare(); shareModel.Id = shareId2; shareModel.ShareTime = DateTime.Now; shareModel.ListId = id1; shareModel.UserId = Guid.NewGuid(); _toDoShareRepository.AddToDoShare(shareModel); await _unitOfWork.SaveAsync(); var result = await _toDoShareRepository.GetListsAsync(shareUser); Assert.Contains(result, t => t.Id == shareId1); Assert.DoesNotContain(result, t => t.Id == shareId2); }