示例#1
0
 public static GroupStudentsViewModel ToModel(this GroupStudents model)
 {
     return(new GroupStudentsViewModel
     {
         Id = model.ID,
         GroupId = model.GroupId,
         StudentId = model.StudentId
     });
 }
示例#2
0
        public void Create(GroupMembersViewModel model, int groupId)
        {
            // Create Group Member : if model.UserTypeId == UserType.Student
            if (model.UserTypeId == (int)UserType.Student)
            {
                var student = _studentRepository.FindById(model.MemberId);
                if (student == null)
                {
                    throw new Exception("student not found");
                }

                var groupStudent = new GroupStudents()
                {
                    GroupId   = groupId,
                    StudentId = model.MemberId
                };
                _groupStudentsRepository.Create(groupStudent);
            }
            // Create Group Member : if model.UserTypeId == UserType.Mentor
            if (model.UserTypeId == (int)UserType.Mentor)
            {
                var mentor = _mentorRepository.FindById(model.MemberId);
                if (mentor == null)
                {
                    throw new Exception("mentor not found");
                }

                var groupMentor = new GroupMentors()
                {
                    GroupId      = groupId,
                    MentorId     = model.MemberId,
                    MentorTypeId = (int)Enum.Parse(typeof(MentorType), model.UserType)
                };
                _groupMentorsRepository.Create(groupMentor);
            }
        }