Exemple #1
0
 public List <Team> GetAllTeams()
 {
     using (StudentsModel db = new StudentsModel())
     {
         return(db.Teams.ToList());
     }
 }
Exemple #2
0
 public List<Team> GetAllTeams()
 {
     using (StudentsModel db = new StudentsModel())
     {
         return db.Teams.ToList();
     }
 }
Exemple #3
0
 public void InsertStudent(Student student)
 {
     using (StudentsModel db = new StudentsModel())
     {
         db.Students.Add(student);
         db.SaveChanges();
     }
 }
Exemple #4
0
 public void InsertStudent(Student student)
 {
     using (StudentsModel db = new StudentsModel())
     {
         db.Students.Add(student);
         db.SaveChanges();
     }
 }
Exemple #5
0
 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();
     }
 }
Exemple #6
0
        public PortManager()
        {
            using (StudentsModel db = new StudentsModel())
            {
            }

            OpenPorts = new List<int>();
            ListAvailableTCPPort(ref OpenPorts);
        }
Exemple #7
0
 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();
     }
 }
Exemple #8
0
 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;
     }
 }
Exemple #9
0
 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;
     }
 }
Exemple #10
0
 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;
     }
 }
Exemple #11
0
 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;
     }
 }
Exemple #12
0
 public UserHelperMain()
 {
     InitializeComponent();
     db = _userInteraction.GetDbContext();
     BatchState.State = UserProcessState.INITIAL;
 }
Exemple #13
0
 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;
     }
 }
Exemple #14
0
 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;
     }
 }