Ejemplo n.º 1
0
        public void ClearAllEntitiesInDatabase()
        {
            using (var db = new SmartPoolContext())
            {
                Console.WriteLine("This action wil clear the entire SmartPool user database (yes/no).");

                if (SecurityCheck() == true)
                {

                    //These commands need to be parameterized
                    db.Database.ExecuteSqlCommand("DELETE [MonitorUnits]");
                    Console.WriteLine("Clearing MonitorUnits...");

                    db.Database.ExecuteSqlCommand("DELETE [Pools]");
                    Console.WriteLine("Clearing pools...");

                    db.Database.ExecuteSqlCommand("DELETE [UserEntities]");
                    Console.WriteLine("Clearing UserEntities...");

                    db.Database.ExecuteSqlCommand("DELETE [RealNames]");
                    Console.WriteLine("Clearing RealNames");
                    Console.WriteLine("************************************************************");
                    Console.WriteLine("******************** All tables cleared! *******************");
                    Console.WriteLine("************************************************************");

                    db.SaveChanges();
                }
                else
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
 public void AddUserToDatabase(User user)
 {
     using (var db = new SmartPoolContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public void GetAllUsers()
        {
            using (var db = new SmartPoolContext())
            {
                var userQuery = from users in db.Users
                    orderby users.FullName.FirstName
                    select users;

                foreach (var user in userQuery)
                {
                    //Console.WriteLine(user.FullName.FirstName + " " + user.FullName.MiddleName + " " + user.FullName.LastName);
                    Console.WriteLine(user.FullName.FirstName);
                    
                }
            }
        }
Ejemplo n.º 4
0
 public void ClearMonitorUnitEntity()
 {
     using (var db = new SmartPoolContext())
     {
         Console.WriteLine("This action wil clear the entire MonitorUnit entity in the user database (yes/no).");
         if (SecurityCheck() == true)
         {
             db.Database.ExecuteSqlCommand("DELETE [MonitorUnits]");
             Console.WriteLine("DELETE [MonitorUnits] run against database: db");
             Console.WriteLine("MonitorUnits was deletes succesfully");
         }
         else
         {
             return;
         }
     }
 }