mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-05 21:37:55 +00:00
Move system updates to the same patch system as members
This commit is contained in:
parent
c5697b33e2
commit
9c1efc7886
12 changed files with 172 additions and 111 deletions
31
PluralKit.Core/Models/Patch/ModelPatchExt.cs
Normal file
31
PluralKit.Core/Models/Patch/ModelPatchExt.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using Dapper;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public static class ModelPatchExt
|
||||
{
|
||||
public static Task<PKSystem> UpdateSystem(this IPKConnection conn, SystemId id, SystemPatch patch)
|
||||
{
|
||||
var (query, pms) = patch.Apply(new UpdateQueryBuilder("systems", "id = @id"))
|
||||
.WithConstant("id", id)
|
||||
.Build("returning *");
|
||||
return conn.QueryFirstAsync<PKSystem>(query, pms);
|
||||
}
|
||||
|
||||
public static Task DeleteSystem(this IPKConnection conn, SystemId id) =>
|
||||
conn.ExecuteAsync("delete from systems where id = @Id", new {Id = id});
|
||||
|
||||
public static Task<PKMember> UpdateMember(this IPKConnection conn, MemberId id, MemberPatch patch)
|
||||
{
|
||||
var (query, pms) = patch.Apply(new UpdateQueryBuilder("members", "id = @id"))
|
||||
.WithConstant("id", id)
|
||||
.Build("returning *");
|
||||
return conn.QueryFirstAsync<PKMember>(query, pms);
|
||||
}
|
||||
|
||||
public static Task DeleteMember(this IPKConnection conn, MemberId id) =>
|
||||
conn.ExecuteAsync("delete from members where id = @Id", new {Id = id});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue