2025-06-10 22:13:06 +08:00
|
|
|
using PMSWPF.Data.Entities;
|
|
|
|
|
|
|
|
|
|
namespace PMSWPF.Data.Repositories;
|
|
|
|
|
|
|
|
|
|
public class DevicesRepositories:BaseRepositories
|
|
|
|
|
{
|
|
|
|
|
public DevicesRepositories()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-12 13:15:55 +08:00
|
|
|
public async Task<int> Add(DbDevice dbDevice)
|
2025-06-10 22:13:06 +08:00
|
|
|
{
|
2025-06-12 13:15:55 +08:00
|
|
|
return await _db.Insertable<DbDevice>(dbDevice).ExecuteCommandAsync();
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|
|
|
|
|
|
2025-06-12 13:15:55 +08:00
|
|
|
public async Task<List<DbDevice>> GetAll()
|
2025-06-10 22:13:06 +08:00
|
|
|
{
|
2025-06-12 13:15:55 +08:00
|
|
|
return await _db.Queryable<DbDevice>().ToListAsync();
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|
2025-06-12 13:15:55 +08:00
|
|
|
public async Task<DbDevice> GetById(int id)
|
2025-06-10 22:13:06 +08:00
|
|
|
{
|
2025-06-12 13:15:55 +08:00
|
|
|
return await _db.Queryable<DbDevice>().FirstAsync(p=>p.Id == id);
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|
|
|
|
|
public async Task<int> DeleteById(int id)
|
|
|
|
|
{
|
2025-06-12 13:15:55 +08:00
|
|
|
return await _db.Deleteable<DbDevice>(new DbDevice() { Id = id }).ExecuteCommandAsync();
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|
|
|
|
|
}
|