public async Task <GamesView> ChangeState(Game game, byte stateId) { try { game.GameStateId = stateId; _wargameContext.Update(game); await _wargameContext.SaveChangesAsync(); return(_wargameContext.GamesView.SingleOrDefault(x => x.Player1Id == game.Player1Id && x.Player2Id == game.Player2Id)); } catch (Exception e) { throw new Exception("Error in friend's acceptation request : " + e.Message); } }
public async Task <bool> setTouched(Position positon, bool touched = true) { try { positon.Touche = touched; _wargameContext.Update(positon); await _wargameContext.SaveChangesAsync(); return(true); } catch (Exception e) { throw new Exception("Error in friend's acceptation request : " + e.Message); } }
public async Task <FriendsView> Update(Friends friend) { try { friend.Indemand = true; _wargameContext.Update(friend); await _wargameContext.SaveChangesAsync(); return(_wargameContext.FriendsView.SingleOrDefault(x => x.Id1 == friend.UserId1 && x.Id2 == friend.UserId2)); } catch (Exception e) { throw new Exception("Erreur lors de l'acceptation de la demande : " + e.Message); } }