示例#1
0
        private async Task AcceptInvitationAsync(ClubInvitation invitation, Guid userId)
        {
            var membership = new ClubMembership {
                UserId = userId, ClubId = invitation.ClubId
            };
            await _context.AddAsync(membership);

            _context.Remove(invitation);
            await _context.SaveChangesAsync();
        }
示例#2
0
        public async Task <Club> Add(string clubName)
        {
            var membership = new ClubMembership {
                User    = await _userService.GetLoggedInUserAsync(),
                IsAdmin = true
            };
            var club = new Club {
                ClubName    = clubName,
                Memberships = new List <ClubMembership>
                {
                    membership
                }
            };
            var entity = await _context.AddAsync(club);

            await _context.SaveChangesAsync();

            return(entity.Entity);
        }
示例#3
0
        public async Task InvokeAsync(HttpContext context, LamaContext userRepository)
        {
            var user = new ApiUser();
            var id   = context.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (!(await userRepository.Users.AnyAsync(x => x.UserId == Guid.Parse(id))))
            {
                var displayName = context.User.FindFirst(ClaimTypes.GivenName).Value;
                user.UserId    = Guid.Parse(id);
                user.GivenName = displayName;
                await userRepository.AddAsync(user);
            }
            await _next(context);
        }
        public async Task InvokeAsync(HttpContext context, LamaContext lamaContext)
        {
            if (context.User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                var user = new ApiUser();
                var id   = context.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                if (!(await lamaContext.Users.AnyAsync(x => x.UserId == Guid.Parse(id))))
                {
                    user.UserId    = Guid.Parse(id);
                    user.UserName  = context.User.FindFirst("emails").Value;
                    user.GivenName = context.User.FindFirst(ClaimTypes.GivenName).Value;
                    await lamaContext.AddAsync(user);

                    await lamaContext.SaveChangesAsync();
                }
            }
            await _next(context);
        }