Ejemplo n.º 1
0
        public Person getPerson(string name)
        {
            Person person = new Person();
            try
            {
                using (projektasEntities database = new projektasEntities())
                {
                    var getperson = database.registracijas.First((p) => p.Name == name);
                    person.id = getperson.Id;
                    person.name = getperson.Name;
                    person.email = getperson.Email;
                    person.password = getperson.Password;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in geting person with name");
            }

            return person;
        }
Ejemplo n.º 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.registracijas)
                        {
                            Person one = new Person();
                            one.name = p.Name;
                            one.id = p.Id;
                            one.password = p.Password;
                            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.password;
                            one.email = p.email;
                            ListOfPerson.Add(one);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in retrieving full table");
            }

            return ListOfPerson;
        }