mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-07 07:00:33 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
77
server/FSO.Server.Database/DA/Roommates/SqlRoommates.cs
Executable file
77
server/FSO.Server.Database/DA/Roommates/SqlRoommates.cs
Executable file
|
@ -0,0 +1,77 @@
|
|||
using Dapper;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace FSO.Server.Database.DA.Roommates
|
||||
{
|
||||
public class SqlRoommates : AbstractSqlDA, IRoommates
|
||||
{
|
||||
public SqlRoommates(ISqlContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Create(DbRoommate roomie)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (uint)Context.Connection.Execute("INSERT INTO fso_roommates (avatar_id, lot_id, permissions_level, is_pending) " +
|
||||
" VALUES (@avatar_id, @lot_id, @permissions_level, @is_pending);", roomie) > 0;
|
||||
} catch (SqlException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateOrUpdate(DbRoommate roomie)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (uint)Context.Connection.Execute("INSERT INTO fso_roommates (avatar_id, lot_id, permissions_level, is_pending) " +
|
||||
"VALUES (@avatar_id, @lot_id, @permissions_level, @is_pending) " +
|
||||
"ON DUPLICATE KEY UPDATE permissions_level = @permissions_level, is_pending = 0", roomie) > 0;
|
||||
}
|
||||
catch (SqlException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public DbRoommate Get(uint avatar_id, int lot_id)
|
||||
{
|
||||
return Context.Connection.Query<DbRoommate>("SELECT * FROM fso_roommates WHERE avatar_id = @avatar_id AND lot_id = @lot_id",
|
||||
new { avatar_id = avatar_id, lot_id = lot_id }).FirstOrDefault();
|
||||
}
|
||||
public List<DbRoommate> GetAvatarsLots(uint avatar_id)
|
||||
{
|
||||
return Context.Connection.Query<DbRoommate>("SELECT * FROM fso_roommates WHERE avatar_id = @avatar_id",
|
||||
new { avatar_id = avatar_id }).ToList();
|
||||
}
|
||||
public List<DbRoommate> GetLotRoommates(int lot_id)
|
||||
{
|
||||
return Context.Connection.Query<DbRoommate>("SELECT * FROM fso_roommates WHERE lot_id = @lot_id",
|
||||
new { lot_id = lot_id }).ToList();
|
||||
}
|
||||
public uint RemoveRoommate(uint avatar_id, int lot_id)
|
||||
{
|
||||
return (uint)Context.Connection.Execute("DELETE FROM fso_roommates WHERE avatar_id = @avatar_id AND lot_id = @lot_id",
|
||||
new { avatar_id = avatar_id, lot_id = lot_id });
|
||||
}
|
||||
|
||||
public bool DeclineRoommateRequest(uint avatar_id, int lot_id)
|
||||
{
|
||||
return Context.Connection.Execute("DELETE FROM fso_roommates WHERE avatar_id = @avatar_id AND lot_id = @lot_id AND is_pending = 1",
|
||||
new { avatar_id = avatar_id, lot_id = lot_id }) > 0;
|
||||
}
|
||||
public bool AcceptRoommateRequest(uint avatar_id, int lot_id)
|
||||
{
|
||||
return Context.Connection.Execute("UPDATE fso_roommates SET is_pending = 0 WHERE avatar_id = @avatar_id AND lot_id = @lot_id AND is_pending = 1",
|
||||
new { avatar_id = avatar_id, lot_id = lot_id }) > 0;
|
||||
}
|
||||
public bool UpdatePermissionsLevel(uint avatar_id, int lot_id, byte level)
|
||||
{
|
||||
return Context.Connection.Execute("UPDATE fso_roommates SET permissions_level = @level WHERE avatar_id = @avatar_id AND lot_id = @lot_id",
|
||||
new { level = level, avatar_id = avatar_id, lot_id = lot_id }) > 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue