Ejemplo n.º 1
0
 public static GroupMentorsViewModel ToModel(this GroupMentors model)
 {
     return(new GroupMentorsViewModel
     {
         Id = model.ID,
         GroupId = model.GroupId,
         MentorId = model.MentorId,
         MentorTypeId = model.MentorTypeId
     });
 }
Ejemplo n.º 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);
            }
        }