public void CreateGroup(GroupViewModel newGroup, int userId) { int groupId = _groupRepository.Add(newGroup.ToEntity()); var role = _roleRepository.Get(r => r.Name.Equals(RoleNames.ROLE_OWNER)).Single(); GroupMember groupMember = new GroupMember() { GroupId = groupId, UserId = userId, RoleId = role.Id, JoinedAt = DateTime.Now }; _groupMemberRepository.AddUserToGroup(groupMember); }