예제 #1
0
        public List<string> getAllNames()
        {
            List<string> ListOfNames = new List<string>();
            try
            {
                using (ProjektasEntities database = new ProjektasEntities())
                {
                    var names = from registracija in database.registrations
                                select registracija.Name;

                    ListOfNames = names.ToList();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in retrieving all names");
            }

            return ListOfNames;
        }
예제 #2
0
        public Person getPerson(string name)
        {
            Person person = new Person();
            try
            {
                using (ProjektasEntities database = new ProjektasEntities())
                {
                    var getperson = database.registrations.First((p) => p.Name == name);
                    person.id = getperson.ID;
                    person.name = getperson.Name;
                    person.email = getperson.Email;
                    person.password = getperson.Pass;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in geting person with name");
            }

            return person;
        }
예제 #3
0
        public List<Person> getTable(string tablename)
        {
            List<Person> ListOfPerson = new List<Person>();
            try
            {
                using (ProjektasEntities database = new ProjektasEntities())
                {
                    if (tablename == "registracija")
                    {


                        foreach (var p in database.registrations)
                        {
                            Person one = new Person();
                            one.name = p.Name;
                            one.id = p.ID;
                            one.password = p.Pass;
                            one.email = p.Email;
                            ListOfPerson.Add(one);
                        }

                    }
                    else if (tablename == "users")
                    {

                        foreach (var p in database.users)
                        {
                            Person one = new Person();
                            one.name = p.Name;
                            one.id = p.Id;
                            one.password = p.Pass;
                            one.email = p.Email;
                            ListOfPerson.Add(one);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in retrieving full table");
            }

            return ListOfPerson;
        }
예제 #4
0
        public void deletePerson(string name)
        {
            try
            {
                using (ProjektasEntities database = new ProjektasEntities())
                {
                    var person = (from registracija in database.registrations
                                  where registracija.Name == name
                                  select registracija).FirstOrDefault();
                    database.registrations.Remove(person);

                    database.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #5
0
        public void updatePerson(string dbName, string name, string email, string password)
        {
            try
            {
                using (ProjektasEntities database = new ProjektasEntities())
                {
                    var person = database.registrations.SingleOrDefault(b => b.Name == dbName);
                    if (person != null)
                    {
                        if (name != "")
                        {
                            person.Name = name;
                        }
                        if (email != "")
                        {
                            person.Email = email;
                        }
                        if (password != "")
                        {
                            person.Pass = password;
                        }

                        database.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #6
0
 public void addPersonToUsers(string name1, string email1, string password1)
 {
     try
     {
         using (ProjektasEntities database = new ProjektasEntities())
         {
             var person = new user
             {
                 Name = name1,
                 Email = email1,
                 Pass = password1
             };
             database.users.Add(person);
             database.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
예제 #7
0
 public void addPersonToRegistration(string name, string email, string password)
 {
     try
     {
         using (ProjektasEntities database = new ProjektasEntities())
         {
             var person = new registration
             {
                 Name = name,
                 Email = email,
                 Pass = password
             };
             database.registrations.Add(person);
             database.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }