Exemple #1
0
        public BaseDTO map(Student student, IList <string> propertyNeeded)
        {
            var studentDTO = new StudentDTO
            {
                StudentFirstName   = (StringListHelper.IsExist(propertyNeeded, "StudentFirstName")) ? student.StudentFirstName : null,
                StudentFatherName  = (StringListHelper.IsExist(propertyNeeded, "StudentFatherName")) ? student.StudentFatherName : null,
                StudentLastName    = (StringListHelper.IsExist(propertyNeeded, "StudentLastName")) ? student.StudentLastName : null,
                StudentMotherName  = (StringListHelper.IsExist(propertyNeeded, "StudentMotherName")) ? student.StudentMotherName : null,
                StudentPlaceLive   = (StringListHelper.IsExist(propertyNeeded, "StudentPlaceLive")) ? student.StudentPlaceLive : null,
                StudentDateBirth   = (StringListHelper.IsExist(propertyNeeded, "StudentDateBirth")) ? student.StudentDateBirth : new DateTime(),
                StudentPlaceBirth  = (StringListHelper.IsExist(propertyNeeded, "StudentPlaceBirth")) ? student.StudentPlaceBirth : null,
                StudentEmail       = (StringListHelper.IsExist(propertyNeeded, "StudentEmail")) ? student.StudentEmail : null,
                StudentPhoneNumber = (StringListHelper.IsExist(propertyNeeded, "StudentPhoneNumber")) ? student.StudentPhoneNumber : null,
                SpecializationName = (StringListHelper.IsExist(propertyNeeded, "SpecializationName")) ? student.Specialization.SpecializationName : null,
            };

            studentDTO.SubCompetetions = new List <SubCompetetionDTO>();
            IList <string> subCompetetionPropertyNeeded = StringListHelper.SearchStringsStartWith(propertyNeeded, "SubCompetetion");

            if (subCompetetionPropertyNeeded.Count() < 1)
            {
                return(studentDTO);
            }

            foreach (TotalMark total in student.Marks)
            {
                var subcompetetionDTO = (SubCompetetionDTO)(new ToSubCompetetionDTOMapper()).map(total.SubCompetetion, subCompetetionPropertyNeeded);
                subcompetetionDTO.StudentMark = (StringListHelper.IsExist(subCompetetionPropertyNeeded, "StudentMark")) ? total.Mark : null;
                studentDTO.SubCompetetions.Add(subcompetetionDTO);
            }
            return(studentDTO);
        }
        public BaseDTO map(SubCompetetion subCompetetion, IList <string> propertyNeeded)
        {
            var subCompetetionDTO = new SubCompetetionDTO
            {
                SubCompetetionName = (StringListHelper.IsExist(propertyNeeded, "SubCompetetionName")) ? subCompetetion.SubCompetetionName : null,
                SubCompetetionDate = (StringListHelper.IsExist(propertyNeeded, "SubCompetetionDate")) ? subCompetetion.SubCompetetionDate : new DateTime(),
                SpecializationName = (StringListHelper.IsExist(propertyNeeded, "SpecializationName")) ? subCompetetion.MainCompetetion.Specialization.SpecializationName : null,
            };

            subCompetetionDTO.Student = new List <StudentDTO>();
            IList <string> studentPropertyNeeded = StringListHelper.SearchStringsStartWith(propertyNeeded, "Student");

            if (studentPropertyNeeded.Count() < 1)
            {
                return(subCompetetionDTO);
            }

            foreach (TotalMark total in subCompetetion.TotalMarks)
            {
                var studentDTO = (StudentDTO)(new ToStudentDTOMapper()).map(total.Student, studentPropertyNeeded);
                studentDTO.SubCompetetionMark = (StringListHelper.IsExist(studentPropertyNeeded, "SubCompetetionMark")) ? total.Mark : null;
                subCompetetionDTO.Student.Add(studentDTO);
            }
            return(subCompetetionDTO);
        }
        public BaseDTO map(MainCompetetion mainCompetetion, IList <string> propertyNeeded)
        {
            var mainCompetetionDTO = new MainCompetetionDTO
            {
                MainCompetetionName = (StringListHelper.IsExist(propertyNeeded, "MainCompetetionName")) ? mainCompetetion.MainCompetetionName : null,
                MainCompetetionID   = (StringListHelper.IsExist(propertyNeeded, "MainCompetetionID")) ? mainCompetetion.MainCompetetionID : -1,
                Specialization      = (SpecializationDTO)(new ToSpecializationDTOMapper()).map(mainCompetetion.Specialization, StringListHelper.SearchStringsStartWith(propertyNeeded, "Specialization"))
            };

            mainCompetetionDTO.SubCompetetions = new List <SubCompetetionDTO>();

            foreach (var subCompetetion in mainCompetetion.SubCompetetions)
            {
                mainCompetetionDTO.SubCompetetions.Add((SubCompetetionDTO)(new ToSubCompetetionDTOMapper()).map(subCompetetion, StringListHelper.SearchStringsStartWith(propertyNeeded, "SubCompetetion")));
            }

            return(mainCompetetionDTO);
        }