* Added machine model, and new database relations
* Added first centralized database config and added machine self-registration into db * Fix database migration with new database * Refactor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Database.Controllers
|
||||
{
|
||||
public class MachinesUsersController : IDisposable
|
||||
{
|
||||
private DatabaseContext dbCtx;
|
||||
|
||||
public MachinesUsersController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public MachinesUsersModel FindByUserId(int machineId, int userId)
|
||||
{
|
||||
return dbCtx
|
||||
.MachinesUsers
|
||||
.Include("Role")
|
||||
.Where(x => x.MachineId == machineId && x.UserId == userId)
|
||||
.FirstOrDefault();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user