Ejemplo n.º 1
0
        public void SaveSchools(PersonDo person)
        {
            List <int> oldSchoolIds = GetSchoolIdsByPersionId(person.Id);
            List <int> newSchoolIds = new List <int>();

            foreach (var school in person.Schools)
            {
                newSchoolIds.Add(school.Id);
            }

            // 添加新关系
            foreach (var id in newSchoolIds)
            {
                if (!oldSchoolIds.Contains(id))
                {
                    AddSchoolIdForPerson(person.Id, id);
                }
            }

            // 删除去除的关系
            foreach (var id in oldSchoolIds)
            {
                if (!newSchoolIds.Contains(id))
                {
                    DelSchoolIdForPerson(person.Id, id);
                }
            }
        }
Ejemplo n.º 2
0
        public PersonDo GetPerson(int id)
        {
            var    condition = "id=?";
            Person person    = dataSet.Select <Person>(condition, id);

            if (person == null)
            {
                return(null);
            }
            PersonDo p = new PersonDo(person);

            p.Schools = GetSchoolsByPersionId(p.Id);
            return(p);
        }
Ejemplo n.º 3
0
        public List <PersonDo> GetPersonList()
        {
            List <Person>   persons    = dataSet.SelectList <Person>(null);
            List <PersonDo> resultList = new List <PersonDo>();

            foreach (var person in persons)
            {
                PersonDo p = new PersonDo(person);
                p.Schools = GetSchoolsByPersionId(p.Id);
                resultList.Add(p);
            }

            return(resultList);
        }