Skip to content
Snippets Groups Projects
Commit 2fd619bc authored by Anders Austlid's avatar Anders Austlid
Browse files

Group creation now takes care of unmarking old primary group

parent 24383edf
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,7 @@ public class GroupController {
Group group = new Group();
group.setGroupName(groupRequest.groupName());
Group createdGroup = groupService.createGroup(group);
User user = optionalUser.get();
......@@ -105,6 +106,12 @@ public class GroupController {
.groupId(createdGroup.getGroupId())
.build();
Optional<UserGroupAsso> oldPrimaryOptional = groupService.findPrimaryUserGroupAssoForUser(user.getUsername());
if(oldPrimaryOptional.isPresent()){
oldPrimaryOptional.get().setPrimaryGroup(false);
groupService.updateUserGroupAsso(oldPrimaryOptional.get());
}
createdGroup.addUser(UserGroupAsso.builder()
.id(userGroupId)
.primaryGroup(true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment