public async Task <List <StoryEntity> > GetStories() { var stories = await _storyRepository .GetAll() .Include(s => s.StoryGroups) .Include(s => s.StoryGroups.Select(sg => sg.Group)) .Include(s => s.User) .ToListAsync(); var storyAssembler = new StoryAssembler(); var storyEntities = storyAssembler.DomainEntitiesToDtos(stories); return(storyEntities); }
public async Task <List <StoryEntity> > GetUserStories(int userId) { var user = await _userRepository .GetAll(u => u.Id == userId) .Include(s => s.Stories) .FirstOrDefaultAsync(); if (user == null) { return(null); } var storyAssembler = new StoryAssembler(); var storyEntities = storyAssembler.DomainEntitiesToDtos(user.Stories); return(storyEntities); }
public async Task <List <StoryEntity> > GetStoriesByUserName(string username) { var user = await _userRepository .GetAll(m => m.Name == username) .Include(s => s.Stories) .FirstOrDefaultAsync(); if (user == null) { return(null); } var storyAssembler = new StoryAssembler(); var storyEntities = storyAssembler.DomainEntitiesToDtos(user.Stories); return(storyEntities); }
public async Task <List <StoryEntity> > GetGroupStories(int groupId) { var group = await _groupRepository .GetAll(u => u.Id == groupId) .Include(s => s.StoryGroups) .Include(s => s.StoryGroups.Select(sg => sg.Story)) .FirstOrDefaultAsync(); if (group == null) { return(null); } var storyAssembler = new StoryAssembler(); var storyEntities = storyAssembler.DomainEntitiesToDtos(group.StoryGroups.Select(sg => sg.Story)); return(storyEntities); }