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(); }
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); }
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); }