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);
        }
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);
        }