Пример #1
0
        public List <Person> getPersons(String id, String surname, String firstanme, persontype persontype = persontype.ALL, bool updatefromsource = false)
        {
            IEnumerable <Person> results = new List <Person>();
            List <IdentityDataLayer.DataModels.Person> presults = new List <IdentityDataLayer.DataModels.Person>();

            // if (!updatefromsource)
            // {

            if (persontype == persontype.ALL)
            {
                presults.AddRange(dbcontext.Persons.Where(p => (id == "" || p.IdentityNo == id) && (surname == "" || p.Surname == surname) && (firstanme == "" || p.Firstname == firstanme)));
            }
            else if (persontype == persontype.STUDENT)
            {
                presults.AddRange(dbcontext.StudentPersons.Where(p => (id == "" || p.Person.IdentityNo == id) && (surname == "" || p.Person.Surname == surname) && (firstanme == "" || p.Person.Firstname == firstanme)).Select(p => p.Person));
            }
            else if (persontype == persontype.STAFF)
            {
                presults.AddRange(dbcontext.StaffPersons.Where(p => (id == "" || p.Person.IdentityNo == id) && (surname == "" || p.Person.Surname == surname) && (firstanme == "" || p.Person.Firstname == firstanme)).Select(p => p.Person));
            }
            else if (persontype == persontype.GENERAL)
            {
                presults.AddRange(dbcontext.GenericPersons.Where(p => (id == "" || p.Person.IdentityNo == id) && (surname == "" || p.Person.Surname == surname) && (firstanme == "" || p.Person.Firstname == firstanme)).Select(p => p.Person));
            }

            // }
            // results = from a in presults select new Person { PersonID=a.IdentityNo,Surname=a.Surname,Firstname=a.Firstname, Address=a.Address, Middlename=a.Middlename, BG=a.BloodGroup, HCN= a.HealthCentreNo, NextOfKin= new Person()  };
            results = from a in presults select new Person(a);

            return(results.ToList());
        }
        public List <Person> filterPeople(String id, String surname, String firstanme, persontype persontype = persontype.ALL)
        {
            //check config for updating from sources
            bool updatefromsource = true;;

            List <Person> results = person_repo.getPersons(id, surname, firstanme, persontype, updatefromsource);

            //treat results
            return(results);
        }