public Reservation GetReservation(ushort port) { using (var context = new ConmanContext()) { var result = context.Reservations.Where(x => x.Port == port).ToList(); return(result.Count > 0 ? result[0] : null); } }
public void checkDB() { //Check that there is an admin using (var context = new ConmanContext()) { var admins = context.Tokens.Where(a => a.Type == 2).ToList(); if (admins.Count == 0) { var token = Conman.Models.Token.CreateAdmin("admin"); context.Tokens.Add(token); Console.WriteLine("No admins present. Created new admin token: " + token.TokenId); context.SaveChanges(); } } }