public async Task <bool> RemoveCollaboratorAsync(DbEntity_Game game, int userId) { var user = await _userService.GetByIdAsync(userId); var success = await RemoveCollaboratorAsync(game, user); return(success); }
public async Task <bool> DeleteByIdAsync(int gameId) { DbEntity_Game game = await GetByIdAsync(gameId); var success = await DeleteAsync(game); return(success); }
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); }
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); }
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); }
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); }
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); }
public async Task <bool> CreateAsync(DbEntity_Game createdGame) { await _ksuGdcContext.Games.AddAsync(createdGame); return(true); }
public async Task <bool> DeleteAsync(DbEntity_Game game) { _ksuGdcContext.Games.Remove(game); return(true); }
public async Task <bool> UpdateAsync(DbEntity_Game updatedGame) { _ksuGdcContext.Update(updatedGame); return(true); }