mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-03-21 17:11:30 +00:00
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
|
using Dapper;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace FSO.Server.Database.DA.Bookmarks
|
|||
|
{
|
|||
|
public class SqlBookmarks : AbstractSqlDA, IBookmarks
|
|||
|
{
|
|||
|
public SqlBookmarks(ISqlContext context) : base(context)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void Create(DbBookmark bookmark)
|
|||
|
{
|
|||
|
Context.Connection.Execute("INSERT INTO fso_bookmarks (avatar_id, type, target_id) " +
|
|||
|
" VALUES (@avatar_id, @type, @target_id)"
|
|||
|
, bookmark);
|
|||
|
}
|
|||
|
|
|||
|
public bool Delete(DbBookmark bookmark)
|
|||
|
{
|
|||
|
return Context.Connection.Execute("DELETE FROM fso_bookmarks WHERE avatar_id = @avatar_id AND type = @type AND target_id = @target_id", bookmark) > 0;
|
|||
|
}
|
|||
|
|
|||
|
public List<DbBookmark> GetByAvatarId(uint avatar_id)
|
|||
|
{
|
|||
|
return Context.Connection.Query<DbBookmark>("SELECT * FROM fso_bookmarks WHERE avatar_id = @avatar_id", new { avatar_id = avatar_id }).ToList();
|
|||
|
}
|
|||
|
|
|||
|
public List<uint> GetAvatarIgnore(uint avatar_id)
|
|||
|
{
|
|||
|
return Context.Connection.Query<uint>("SELECT target_id FROM fso_bookmarks WHERE avatar_id = @avatar_id AND type = 5", new { avatar_id = avatar_id }).ToList();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|