moved time to IDataModel, started making currency stuff
This commit is contained in:
parent
9beeaf6a0e
commit
ca5f2a3d8f
@ -41,13 +41,13 @@ namespace NadekoBot.Classes {
|
||||
|
||||
internal List<T> GetAllRows<T>() where T : IDataModel, new() {
|
||||
using (var _conn = new SQLiteConnection(_filePath)) {
|
||||
return _conn.Table<T>().Where(t => true).ToList();
|
||||
return _conn.Table<T>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
internal T Delete<T>(int Id) where T : IDataModel, new() {
|
||||
using (var _conn = new SQLiteConnection(_filePath)) {
|
||||
var found = _conn.Table<T>().Where(t => t.Id == Id).FirstOrDefault();
|
||||
var found = _conn.Find<T>(Id);
|
||||
if (found != null)
|
||||
_conn.Delete<T>(found.Id);
|
||||
return found;
|
||||
@ -59,7 +59,7 @@ namespace NadekoBot.Classes {
|
||||
/// </summary>
|
||||
internal void Save<T>(T o) where T : IDataModel, new() {
|
||||
using (var _conn = new SQLiteConnection(_filePath)) {
|
||||
var found = _conn.Table<T>().Where(t => t.Id == o.Id).FirstOrDefault();
|
||||
var found = _conn.Find<T>(o.Id);
|
||||
if (found == null)
|
||||
_conn.Insert(o, typeof(T));
|
||||
else
|
||||
|
@ -14,7 +14,5 @@ namespace NadekoBot.Classes._DataModels {
|
||||
[JsonProperty("byeChannel")]
|
||||
public long ByeChannelId { get; set; } = 0;
|
||||
public string ByeText { get; set; } = "%user% has left the server.";
|
||||
[JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,5 @@ namespace NadekoBot.Classes._DataModels {
|
||||
public long ChannelId { get; set; }
|
||||
public string ChannelName { get; set; }
|
||||
public string CommandName { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
||||
|
6
NadekoBot/Classes/_DataModels/Currency.cs
Normal file
6
NadekoBot/Classes/_DataModels/Currency.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
class Currency : IDataModel {
|
||||
public long UserId { get; set; }
|
||||
public long Value { get; set; }
|
||||
}
|
||||
}
|
6
NadekoBot/Classes/_DataModels/CurrencyTransaction.cs
Normal file
6
NadekoBot/Classes/_DataModels/CurrencyTransaction.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
class CurrencyTransaction : IDataModel {
|
||||
public string Reason { get; set; }
|
||||
public int Value { get; set; }
|
||||
}
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
using SQLite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
class IDataModel {
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; } = DateTime.Now;
|
||||
public IDataModel() { }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
class Request : IDataModel {
|
||||
public string UserName { get; set; }
|
||||
public long UserId { get; set; }
|
||||
@ -8,7 +6,5 @@ namespace NadekoBot.Classes._DataModels {
|
||||
public long ServerId { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("Request")]
|
||||
public string RequestText { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,5 @@ namespace NadekoBot.Classes._DataModels {
|
||||
public int OnlineUsers { get; set; }
|
||||
public TimeSpan Uptime { get; set; }
|
||||
public int RealOnlineUsers { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
namespace NadekoBot.Classes._DataModels {
|
||||
class TypingArticle : IDataModel {
|
||||
public string Text { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,8 @@
|
||||
<Compile Include="Classes\Music\SoundCloud.cs" />
|
||||
<Compile Include="Classes\_DataModels\AnnouncementModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\CommandModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\Currency.cs" />
|
||||
<Compile Include="Classes\_DataModels\CurrencyTransaction.cs" />
|
||||
<Compile Include="Classes\_DataModels\IDataModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\RequestModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\StatsModel.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user