fa485d902b
* Added first centralized database config and added machine self-registration into db * Fix database migration with new database * Refactor
37 lines
870 B
C#
37 lines
870 B
C#
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();
|
|
|
|
}
|
|
}
|
|
}
|