public static StudentProfile ToStudentProfile(StudentProfileInputModel model)
        {
            StudentProfile profile = new StudentProfile();

            profile.Description = model.Description;

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

                if (model.StudyProgramName != null)
                {
                    profile.StudyProgram = profile.Faculty.StudyPrograms.Values.First(sp => sp.Name == model.StudyProgramName);

                    if (model.StudyProgramSpecializationName != null)
                    {
                        profile.StudyProgramSpecialization = profile.StudyProgram.StudyProgramSpecializations.Values.First(sps => sps.Name == model.StudyProgramSpecializationName);
                    }
                }
            }

            profile.StudyCycle = model.StudyCycle ?? null;
            profile.StudyYear  = model.StudyYear ?? null;

            return(profile);
        }
Beispiel #2
0
        public static Project ToProject(ProjectInputModel model)
        {
            Project project = new Project
            {
                AuthorId      = User.CurrentUserId,
                Title         = model.Title,
                ProjectStatus = ProjectStatus.Active,
                Description   = model.Description,
                StudyField    = ((App)App.Current).faculties.GetAllStudyFields().First(sf => sf.Name == model.StudyFieldName)
            };

            if (model.StartDate != null)
            {
                project.StartDate = model.StartDate.DateTime;
            }

            if (model.EndDate != null)
            {
                project.EndDate = model.EndDate.Date;
            }

            foreach (var item in model.CollaboratorProfileInputModels)
            {
                if (item is StudentProfileInputModel sInputModel)
                {
                    project.CollaboratorProfiles.Add(StudentProfileInputModel.ToStudentProfile(sInputModel));
                }
                else if (item is FacultyMemberProfileInputModel fmInputModel)
                {
                    project.CollaboratorProfiles.Add(FacultyMemberProfileInputModel.ToFacultyMemberProfile(fmInputModel));
                }
            }

            foreach (var tagName in model.TagNames)
            {
                project.Tags.Add(((App)App.Current).tags.GetAll().First(t => t.Name == tagName));
            }

            return(project);
        }