예제 #1
0
        //Location methods
        public void deleteLocation(int id)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qlocation in db.location
                                where qlocation.location_id == id
                                select qlocation;

                    foreach (location elocation in query)
                    {
                        elocation.deleted = true;
                    }

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #2
0
        public void delete(int id)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qGymnast in db.gymnast
                                where qGymnast.gymnast_id == id
                                select qGymnast;

                    foreach (gymnast eGymnast in query)
                    {
                        eGymnast.deleted = true;
                    }

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #3
0
        public void createVaultKind(vaultkind vaultKind)
        {
            using (var db = new DataContext())
            {
                db.vaultkind.Add(vaultKind);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
예제 #4
0
        public void create(gymnast gymnast)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    db.gymnast.Add(gymnast);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #5
0
        public void createVaultnumber(vaultnumber vaultnumber)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    db.vaultnumber.Add(vaultnumber);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #6
0
        public void create(vault vault)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    if (vault.gymnast != null)
                    {
                        db.gymnast.Attach(vault.gymnast);
                    }

                    if (vault.location != null)
                    {
                        db.location.Attach(vault.location);
                    }

                    if (vault.vaultkind != null)
                    {
                        db.vaultkind.Attach(vault.vaultkind);
                    }

                    if (vault.vaultnumber != null)
                    {
                        db.vaultnumber.Attach(vault.vaultnumber);
                    }

                    db.vault.Add(vault);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #7
0
 public List<vaultnumber> getVaultNumbers()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qVaultNumbers in db.vaultnumber
                     where qVaultNumbers.deleted == false
                     select qVaultNumbers
                 ).ToList();
         }
         List<vaultnumber> list = new List<vaultnumber>();
         return list;
     }
 }
예제 #8
0
 public List<String> getVaultKindNames()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qVaultKind in db.vaultkind
                     where qVaultKind.deleted == false
                     select qVaultKind.name
             ).ToList();
         }
         List<String> list = new List<String>();
         return list;
     }
 }
예제 #9
0
        //Vaultnumber methods
        public void deleteVaultNumber(int id)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qvaultnumber in db.vaultnumber
                                where qvaultnumber.vaultnumber_id == id
                                select qvaultnumber;

                    foreach (vaultnumber evaultnumber in query)
                    {
                        evaultnumber.deleted = true;
                    }

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #10
0
 public List<gymnast> getGymnastCollection()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qGymnast in db.gymnast
                     where qGymnast.deleted == false
                     select qGymnast
             ).ToList();
         }
         List<gymnast> list = new List<gymnast>();
         return list;
     }
 }
예제 #11
0
        public ObservableCollection<vaultkind> readVaultKinds()
        {
            ObservableCollection<vaultkind> vaultKinds = new ObservableCollection<vaultkind>();

            using (var db = new DataContext())
            {
                var query = from qvaultkind in db.vaultkind
                            where qvaultkind.deleted == false
                            select qvaultkind;

                foreach (vaultkind vaultKind in query)
                {
                    vaultKinds.Add(vaultKind);
                }
            }

            return vaultKinds;
        }
예제 #12
0
        public void update(vault vault)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = (from qVault in db.vault
                                 where qVault.vault_id == vault.vault_id
                                 select qVault).First();

                    query.gymnast_id = vault.gymnast_id;
                    query.timestamp = vault.timestamp;
                    query.vault_id = vault.vault_id;
                    query.location_id = vault.location_id;
                    query.vaultkind_id = vault.vaultkind_id;
                    query.vaultnumber_id = vault.vaultnumber_id;
                    query.rating_star = vault.rating_star;
                    query.rating_official_D = vault.rating_official_D;
                    query.rating_official_E = vault.rating_official_E;
                    query.penalty = vault.penalty;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {

                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #13
0
        public void updateVaultnumber(vaultnumber vaultnumber)
        {
            if (vaultnumber.vaultnumber_id != 0)
            {
                using (var db = new DataContext())
                {
                    var query = from qvaultnumber in db.vaultnumber
                                where qvaultnumber.vaultnumber_id == vaultnumber.vaultnumber_id
                                select qvaultnumber;

                    foreach (vaultnumber evaultnumber in query)
                    {
                        evaultnumber.code = vaultnumber.code;
                        evaultnumber.description = vaultnumber.description;
                        evaultnumber.difficulty = vaultnumber.difficulty;
                        evaultnumber.male_female = vaultnumber.male_female;
                    }

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
            else
            {
                createVaultnumber(vaultnumber);
            }
        }
예제 #14
0
        public void updateVaultKind(vaultkind vaultKind)
        {
            if (vaultKind.vaultkind_id != 0)
            {
                using (var db = new DataContext())
                {
                    var query = (from qvaultkind in db.vaultkind
                                where qvaultkind.vaultkind_id == vaultKind.vaultkind_id
                                select qvaultkind).First();

                    query.name = vaultKind.name;
                    query.description = vaultKind.description;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
            else
            {
                createVaultKind(vaultKind);
            }
        }
예제 #15
0
        public void updateLocation(location location)
        {
            if (location.location_id != 0)
            {
                using (var db = new DataContext())
                {
                    bool dbexist = db.Database.Exists();
                    if (dbexist == true)
                    {
                        var query = from qlocation in db.location
                                    where qlocation.location_id == location.location_id
                                    select qlocation;

                        foreach (location elocation in query)
                        {
                            elocation.name = location.name;
                            elocation.description = location.description;
                        }

                        try
                        {
                            db.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
            }
            else
            {
                createLocation(location);
            }
        }
예제 #16
0
        public ObservableCollection<vaultnumber> readVaultnumbers()
        {
            ObservableCollection<vaultnumber> vaultnumbers = new ObservableCollection<vaultnumber>();

            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qvaultnumber in db.vaultnumber
                                where qvaultnumber.deleted == false
                                select qvaultnumber;

                    foreach (vaultnumber evaultnumber in query)
                    {
                        vaultnumbers.Add(evaultnumber);
                    }
                }
            }
            return vaultnumbers;
        }
예제 #17
0
 public List<vault> getVaults()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qVault in db.vault.Include("gymnast").Include("vaultkind").Include("vaultnumber").Include("location")
                     where qVault.deleted == false
                     select qVault
             ).ToList();
         }
         List<vault> list = new List<vault>();
         return list;
     }
 }
예제 #18
0
        public gymnast read(int id)
        {
            using (var db = new DataContext())
            {
                var query = from gym in db.gymnast
                            where gym.gymnast_id == id
                            select gym;
            }

            return null;
        }
예제 #19
0
 public vault read(int id)
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             var query = (from qVault in db.vault.Include("gymnast").Include("vaultnumber").Include("location").Include("vaultkind")
                          where qVault.vault_id == id
                          select qVault).FirstOrDefault();
             return query;
         }
         vault v = new vault();
         return v;
     }
 }
예제 #20
0
        public ObservableCollection<location> readLocations()
        {
            ObservableCollection<location> locations = new ObservableCollection<location>();

            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qlocation in db.location
                                where qlocation.deleted == false
                                select qlocation;

                    foreach (location elocation in query)
                    {
                        locations.Add(elocation);
                    }
                }
            }

            return locations;
        }
예제 #21
0
        public Boolean login(string username, string password)
        {
            Boolean correctLoginVariables = false;

            String passwordToHash   = password + SALT;
            byte[] passwordBytes    = Encoding.ASCII.GetBytes(passwordToHash);

            MD5 hasher              = MD5.Create();
            passwordBytes           = hasher.ComputeHash(passwordBytes);

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < passwordBytes.Length; i++)
            {
                sb.Append(passwordBytes[i].ToString("x2"));
            }
            String hashedPassword = sb.ToString();

            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qUser in db.user
                                where qUser.username == username && qUser.password == hashedPassword
                                select qUser;

                    foreach (user eUser in query)
                    {
                        if (eUser != null)
                        {
                            _isLoggedIn = true;
                            correctLoginVariables = true;
                        }
                    }
                }
            }

            return correctLoginVariables;
        }
예제 #22
0
        public void delete(int id)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = (from qVault in db.vault
                                 where qVault.vault_id == id
                                 select qVault).First();

                    query.deleted = true;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #23
0
        public void update(gymnast gymnast)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qGymnast in db.gymnast
                                where qGymnast.gymnast_id == gymnast.gymnast_id
                                select qGymnast;

                    foreach (gymnast eGymnast in query)
                    {
                        eGymnast.turnbondID = gymnast.turnbondID;
                        eGymnast.gender = gymnast.gender;
                        eGymnast.nationality = gymnast.nationality;
                        eGymnast.length = gymnast.length;
                        eGymnast.weight = gymnast.weight;
                        eGymnast.picture = gymnast.picture;
                        eGymnast.birthdate = gymnast.birthdate;
                        eGymnast.name = gymnast.name;
                        eGymnast.surname = gymnast.surname;
                        eGymnast.surname_prefix = gymnast.surname_prefix;
                        eGymnast.note = gymnast.note;
                    }

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
예제 #24
0
 public List<String> getGymnastNames()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qGymnast in db.gymnast
                     where qGymnast.deleted == false
                     select qGymnast.name + (qGymnast.surname_prefix.Length > 0 ? " " + qGymnast.surname_prefix : "") + " " + qGymnast.surname
             ).ToList();
         }
         List<String> list = new List<String>();
         return list;
     }
 }
예제 #25
0
        public String getLaserData(int id)
        {
            using (var db = new DataContext())
            {
                bool dbexist = db.Database.Exists();
                if (dbexist == true)
                {
                    var query = from qVault in db.vault
                                where qVault.vaultnumber_id == id
                                select qVault;

                    String data = String.Empty;

                    foreach (vault eVault in query)
                    {
                        data = eVault.graphdata;
                    }

                    return data;
                }
                return " ";
            }
        }
예제 #26
0
 public List<location> getLocations()
 {
     using (var db = new DataContext())
     {
         bool dbexist = db.Database.Exists();
         if (dbexist == true)
         {
             return (from qLocation in db.location
                     where qLocation.deleted == false
                     select qLocation
                 ).ToList();
         }
         List<location> list = new List<location>();
         return list;
     }
 }
예제 #27
0
 public void CheckNetworkConnection()
 {
     bool isConnected = false;
     try
     {
         using (var db = new DataContext())
         {
             bool dbexist = db.Database.Exists();
             if (dbexist == true)
             {
                 isConnected = true;
             }
         }
     }
     catch(Exception e)
     {
         isConnected = false;
     }
     finally
     {
         if (!isConnected)
         {
             IsOfflineMode = true;
             MessageBox.Show("No active network connection could be found.\r\n Some functionalities will not be available", "Not connected to the internet", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
예제 #28
0
        // VaultKind methods
        public void deleteVaultKind(int id)
        {
            using (var db = new DataContext())
            {
                var vaultKind = (from qvaultkind in db.vaultkind
                                where qvaultkind.vaultkind_id == id
                                select qvaultkind).First();

                vaultKind.deleted = true;

                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }