-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed unused class Change some config
- Loading branch information
Showing
9 changed files
with
171 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using LiteDB; | ||
using System; | ||
using System.IO; | ||
|
||
|
||
namespace AudioPlayer | ||
{ | ||
public class PlayerRepository : IDisposable | ||
{ | ||
private readonly LiteDatabase _db; | ||
|
||
public PlayerRepository(string databasePath) | ||
{ | ||
var directory = Path.GetDirectoryName(databasePath); | ||
if (!Directory.Exists(directory)) | ||
{ | ||
Directory.CreateDirectory(directory); | ||
} | ||
|
||
_db = new LiteDatabase(databasePath); | ||
|
||
var players = _db.GetCollection<PlayerDB>("t_players"); | ||
players.EnsureIndex(x => x.UserId, true); | ||
|
||
} | ||
|
||
public PlayerDB GetPlayerByUserId(string userId) | ||
{ | ||
var players = _db.GetCollection<PlayerDB>("t_players"); | ||
var player = players.FindOne(x => x.UserId == userId); | ||
return player; | ||
} | ||
|
||
public void InsertPlayer(PlayerDB player) | ||
{ | ||
var players = _db.GetCollection<PlayerDB>("t_players"); | ||
players.Insert(player); | ||
} | ||
|
||
public void UpdatePlayer(PlayerDB player) | ||
{ | ||
var players = _db.GetCollection<PlayerDB>("t_players"); | ||
players.Update(player); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_db.Dispose(); | ||
} | ||
} | ||
|
||
public class PlayerDB | ||
{ | ||
public int Id { get; set; } | ||
public string UserId { get; set; } | ||
public int Mute { get; set; } | ||
} | ||
|
||
} |
Oops, something went wrong.