Example #1
0
        public async Task <bool> RemoveCollaboratorAsync(DbEntity_Game game, int userId)
        {
            var user = await _userService.GetByIdAsync(userId);

            var success = await RemoveCollaboratorAsync(game, user);

            return(success);
        }
Example #2
0
        public async Task <bool> DeleteByIdAsync(int gameId)
        {
            DbEntity_Game game = await GetByIdAsync(gameId);

            var success = await DeleteAsync(game);

            return(success);
        }
Example #3
0
        public async Task <bool> RemoveCollaboratorAsync(DbEntity_Game game, DbEntity_User user)
        {
            var collaborator = await GetCollaboratorAsync(game.GameId, user.UserId);

            var success = await RemoveCollaboratorAsync(collaborator);

            return(success);
        }
Example #4
0
        public async Task <List <DbEntity_User> > GetCollaboratorsAsync(DbEntity_Game game)
        {
            var users = await _ksuGdcContext.GameUsers
                        .Where(gu => gu.GameId == game.GameId)
                        .Include(gu => gu.User)
                        .Select(gu => gu.User)
                        .ToListAsync();

            return(users);
        }
Example #5
0
        public async Task <bool> AddCollaboratorAsync(DbEntity_Game game, DbEntity_User user)
        {
            var collaborator = new DbEntity_GameUser()
            {
                GameId = game.GameId,
                UserId = user.UserId
            };
            var success = await AddCollaboratorAsync(collaborator);

            return(success);
        }
Example #6
0
        public async Task <List <DbEntity_User> > GetNonCollaboratorsAsync(DbEntity_Game game)
        {
            var collaborators = _ksuGdcContext.GameUsers
                                .Where(gu => gu.GameId == game.GameId)
                                .Select(gu => gu.UserId);
            var nonCollaborators = await _ksuGdcContext.Users
                                   .Where(u => !(collaborators.Contains(u.UserId)))
                                   .ToListAsync();

            return(nonCollaborators);
        }
Example #7
0
        public async Task <DbEntity_Image> GetImageAsync(DbEntity_Game game)
        {
            var image = await _ksuGdcContext.GameImages
                        .Where(gi => gi.GameId == game.GameId)
                        .Select(gi => gi.Image)
                        .FirstOrDefaultAsync();

            if (image == null)
            {
                throw new NotFoundException($"No image with game id '{game.GameId}' was found.");
            }
            return(image);
        }
Example #8
0
        public async Task <bool> CreateAsync(DbEntity_Game createdGame)
        {
            await _ksuGdcContext.Games.AddAsync(createdGame);

            return(true);
        }
Example #9
0
 public async Task <bool> DeleteAsync(DbEntity_Game game)
 {
     _ksuGdcContext.Games.Remove(game);
     return(true);
 }
Example #10
0
 public async Task <bool> UpdateAsync(DbEntity_Game updatedGame)
 {
     _ksuGdcContext.Update(updatedGame);
     return(true);
 }