示例#1
0
        public void AddUserToDivisions(UserForRegisterDto userForRegister, User user, UserForDetailedDto userForDetailed)
        {
            if (userForRegister.Year != 0)
            {
                var specialization = _specializationsRepo.GetSpecializationByName(userForRegister.Specialization);

                var group = _groupsRepo.GetGroupByName(userForRegister.Group);

                var subGroup = _subGroupsRepo.GetSubGroupByName(userForRegister.SubGroup);

                UserSpecialization userSpecialization = new UserSpecialization
                {
                    UserId           = user.Id,
                    SpecializationId = specialization.Id
                };

                _genericsRepo.Add(userSpecialization);

                UserGroup userGroup = new UserGroup
                {
                    UserId  = user.Id,
                    GroupId = group.Id
                };

                _genericsRepo.Add(userGroup);

                UserSubGroup userSubGroup = new UserSubGroup
                {
                    UserId     = user.Id,
                    SubGroupId = subGroup.Id
                };

                _genericsRepo.Add(userSubGroup);

                userForDetailed.Specialization = specialization.Name;
                userForDetailed.Group          = group.Name;
                userForDetailed.SubGroup       = subGroup.Name;

                _genericsRepo.SaveAll();
            }
        }