예제 #1
0
        public async Task <ActionResult <GroupWithUsers> > Post(CreateGroupRequest createGroupRequest)
        {
            string currentUserId = HttpContext.User.Claims.FirstOrDefault(x => x.Type == JwtRegisteredClaimNames.Sub)?.Value;

            createGroupRequest.UserIds.Add(currentUserId);

            GroupWithUsers newGroup = await _groupService.CreateNewGroupAsync(createGroupRequest, currentUserId);

            return(newGroup);
        }
        public GroupWithUsers CreateGroupWithUsersModel(int id, AppContext context)
        {
            var userGroup = new Repository <UserGroup>(context).Get().FirstOrDefault(ug => ug.Id == id);
            var allUsers  = new Repository <User>(context).Get().ToList();

            var groupWithUsers = new GroupWithUsers
            {
                GroupId = id,
                Users   = allUsers.Select(u => Create(u, userGroup)).ToList()
            };

            return(groupWithUsers);
        }