Example #1
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;
        }
Example #2
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;
        }