Example #1
0
        public void ClearEntitiesInDatabase()
        {
            using (var db = new SpContext())
            {
                Console.WriteLine("This action wil clear the entire SmartPool user database (yes/no).");

                if (SecurityCheck() == true)
                {
                    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! *******************");

                    db.SaveChanges();
                }
                else
                {
                    return;
                }
            }
        }
Example #2
0
 public void AddUserToDatabase(UserEntity userEntity)
 {
     using (var db = new SpContext())
     {
         db.UserEntities.Add(userEntity);
         db.SaveChanges();
     }
 }
Example #3
0
 public void ClearMonitorUnitEntity()
 {
     using (var db = new SpContext())
     {
         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;
         }
     }
 }
Example #4
0
        public void GetQueryForRealNamesInDatabase()
        {
            using (var db = new SpContext())
            {
                var query1 = from realFirstNames in db.RealNames
                             orderby realFirstNames.FirstName
                             select realFirstNames;

                var query2 = from realMiddleNames in db.RealNames
                             orderby realMiddleNames.MiddleName
                             select realMiddleNames;

                var query3 = from realSurNames in db.RealNames
                             orderby realSurNames.SurName
                             select realSurNames;

                foreach (var realFirstNameItem in query1)
                {
                    Console.WriteLine(realFirstNameItem.FirstName);
                }

            }
        }
Example #5
0
        public void AddPoolToUserInDatabase(/*UserEntity user,*/ Pool pool)
        {

            using (var db = new SpContext())
            {
                throw new NotImplementedException();
            }

            Console.WriteLine("The pool: {0} was added to user: .", pool.PoolName/*, user.Name.FirstName*/);
        }