public List <Team> GetAllTeams() { using (StudentsModel db = new StudentsModel()) { return(db.Teams.ToList()); } }
public List<Team> GetAllTeams() { using (StudentsModel db = new StudentsModel()) { return db.Teams.ToList(); } }
public void InsertStudent(Student student) { using (StudentsModel db = new StudentsModel()) { db.Students.Add(student); db.SaveChanges(); } }
public void CreateTeam(string name, DateTime startDate, DateTime endDate) { using (StudentsModel db = new StudentsModel()) { db.Teams.Add(new Models.Team { Name = name, StartDate = startDate, EndDate = endDate, CreatedDate = DateTime.Now }); db.SaveChanges(); } }
public PortManager() { using (StudentsModel db = new StudentsModel()) { } OpenPorts = new List<int>(); ListAvailableTCPPort(ref OpenPorts); }
public void CreateDBUser(string databaseName, string username) { try { using (StudentsModel ctx = new StudentsModel()) { ctx.Database.ExecuteSqlCommand("use " + databaseName + "; CREATE USER " + username + " FOR LOGIN " + username); BatchState.State = UserProcessState.SQL_USER_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_USER_ERROR; throw; } }
public void CreateDBServerLogin(string username, string password) { try { using (StudentsModel ctx = new StudentsModel()) { ctx.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "CREATE LOGIN " + username + " WITH PASSWORD = '******'"); BatchState.State = UserProcessState.SQL_LOGIN_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_LOGIN_ERROR; throw; } }
public void CreateDatabase(string databaseName) { try { using (StudentsModel ctx = new StudentsModel()) { string cmd = "CREATE DATABASE [" + databaseName + "]"; ctx.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd); BatchState.State = UserProcessState.SQL_DB_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_DB_ERROR; throw; } }
public void AssignRoleToUser(string databaseName, string username) { try { using (StudentsModel ctx = new StudentsModel()) { ctx.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "use " + databaseName + "; exec sp_addrolemember 'db_owner', " + username); BatchState.State = UserProcessState.SQL_ROLE_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_ROLE_ERROR; throw; } }
public UserHelperMain() { InitializeComponent(); db = _userInteraction.GetDbContext(); BatchState.State = UserProcessState.INITIAL; }
public void InsertUserWithCredentialsOnTeam(Student student, Credentials cred, int teamId) { try { using (StudentsModel ctx = new StudentsModel()) { student.Credentials = cred; student.TeamId = teamId; ctx.Students.Add(student); ctx.SaveChanges(); BatchState.State = UserProcessState.SQL_INSERT_USER_DATA_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_INSERT_USER_DATA_ERROR; throw; } }
public void DeleteDBServerLogin(string userName) { try { using (StudentsModel ctx = new StudentsModel()) { ctx.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "DROP LOGIN " + userName); BatchState.State = UserProcessState.SQL_LOGIN_DELETE_OK; } } catch (Exception) { BatchState.State = UserProcessState.SQL_LOGIN_DELETE_ERROR; throw; } }