public static FacultyMemberProfileOverview FromFacultyMemberProfile(FacultyMemberProfile profile)
        {
            FacultyMemberProfileOverview model = new FacultyMemberProfileOverview
            {
                FacultyName    = profile.Faculty != null ? profile.Faculty.Name : null,
                StudyFieldName = profile.StudyField != null ? profile.StudyField.Name : null
            };

            return(model);
        }
        public static FacultyMemberProfile ToFacultyMemberProfile(FacultyMemberProfileInputModel model)
        {
            FacultyMemberProfile profile = new FacultyMemberProfile();

            if (model.FacultyName != null)
            {
                profile.Faculty = ((App)App.Current).faculties.GetAll().First(f => f.Name == model.FacultyName);
            }

            if (model.StudyFieldName != null)
            {
                profile.StudyField = ((App)App.Current).faculties.GetAllStudyFields().First(sf => sf.Name == model.StudyFieldName);
            }

            return(profile);
        }
        private async Task ReadCollaboratorProfilesInfo(MySqlCommand command, int id, Project project)
        {
            string commandText = @"SELECT collaborator_profile_id, collaborator_profile.description, user_account_type_id, 
	                               student_profile.cycle, study_year,
	                               faculty.faculty_id, study_program.study_program_id, study_program_specialization.study_program_specialization_id,       
	                               study_field.study_field_id
                                   FROM collaborator_profile
                                   LEFT OUTER JOIN student_profile USING(collaborator_profile_id)
                                   LEFT OUTER JOIN faculty_member_profile USING(collaborator_profile_id)
                                   LEFT OUTER JOIN faculty ON student_profile.faculty_id = faculty.faculty_id OR faculty_member_profile.faculty_id = faculty.faculty_id
                                   LEFT OUTER JOIN study_program ON student_profile.study_program_id = study_program.study_program_id
                                   LEFT OUTER JOIN study_program_specialization ON student_profile.study_program_specialization_id = study_program_specialization.study_program_specialization_id
                                   LEFT OUTER JOIN study_field ON faculty_member_profile.study_field_id = study_field.study_field_id
                                   WHERE project_id = @id";

            command.CommandText = commandText;
            command.Parameters.Clear();
            command.Parameters.Add(new MySqlParameter
            {
                DbType        = DbType.Int32,
                ParameterName = "@id",
                Value         = id
            });

            using (var reader = await command.ExecuteReaderAsync())
            {
                if (reader.HasRows)
                {
                    while (await reader.ReadAsync())
                    {
                        CollaboratorProfileType profileType = (CollaboratorProfileType)Enum.ToObject(typeof(CollaboratorProfileType), reader.GetInt32(2));

                        if (profileType is CollaboratorProfileType.Student)
                        {
                            StudentProfile profile = new StudentProfile
                            {
                                CollaboratorProfileId = reader.GetInt32(0),
                                Description           = !reader.IsDBNull(1) ? reader.GetString(1) : null,
                                StudyCycle            = !reader.IsDBNull(3) ? (int?)reader.GetInt32(3) : null,
                                StudyYear             = !reader.IsDBNull(4) ? (int?)reader.GetInt32(4) : null,

                                Added = false
                            };

                            int?facultyId = !reader.IsDBNull(5) ? (int?)reader.GetInt32(5) : null;
                            if (facultyId != null)
                            {
                                profile.Faculty = ((App)App.Current).faculties.GetFacultyById((int)facultyId);

                                int?programId = !reader.IsDBNull(6) ? (int?)reader.GetInt32(6) : null;
                                if (programId != null)
                                {
                                    profile.StudyProgram = profile.Faculty.StudyPrograms[(int)programId];

                                    int?specializationId = !reader.IsDBNull(7) ? (int?)reader.GetInt32(7) : null;
                                    if (specializationId != null)
                                    {
                                        profile.StudyProgramSpecialization = profile.StudyProgram.StudyProgramSpecializations[(int)specializationId];
                                    }
                                }
                            }

                            project.CollaboratorProfiles.Add(profile);
                        }
                        else if (profileType is CollaboratorProfileType.FacultyMember)
                        {
                            FacultyMemberProfile profile = new FacultyMemberProfile
                            {
                                CollaboratorProfileId = reader.GetInt32(0),
                                Description           = !reader.IsDBNull(1) ? reader.GetString(1) : null,

                                Added = false
                            };

                            int?facultyId = !reader.IsDBNull(5) ? (int?)reader.GetInt32(5) : null;
                            if (facultyId != null)
                            {
                                profile.Faculty = ((App)App.Current).faculties.GetFacultyById((int)facultyId);
                            }

                            int?studyFieldId = !reader.IsDBNull(8) ? (int?)reader.GetInt32(8) : null;
                            if (studyFieldId != null)
                            {
                                profile.StudyField = ((App)App.Current).faculties.GetStudyFieldById((int)studyFieldId);
                            }

                            project.CollaboratorProfiles.Add(profile);
                        }
                    }
                }
            }
        }