public async Task <ActionResult <QrCodeDto> > PostQrCode(QrCodeDto qrCodeDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Get le login dans le token var identity = HttpContext.User.Identity as ClaimsIdentity; string login = identity.FindFirst("login").Value; // Requete db pour récupere l'id du login var participant = await _participantRepository.GetParticipantByLoginAsync(login); if (participant == null) { return(BadRequest(new { message = "No participant" })); } try { await _qrCodesRepository.CreateQrCodeAsync(qrCodeDto, participant.ParticipantID); } catch (DbUpdateException) { return(BadRequest(new { message = "The id already exist" })); } return(CreatedAtAction("GetQrCode", qrCodeDto)); }
public async Task <QrCodeDto> CreateQrCodeAsync(QrCodeDto qrCode, long participantID) { QrCode qrCodeParticipant = _mapper.Map <QrCode>(qrCode); qrCodeParticipant.ParticipantID = participantID; _context.QrCode.Add(qrCodeParticipant); await _context.SaveChangesAsync(); return(qrCode); }
public static async Task NotifyQrCodeReceived(QrCodeDto qrCodeDto) => await OnQrCodeReceivedEvent?.Invoke(qrCodeDto);
private async Task AuthenticationBase_OnQrCodeReceivedEvent(QrCodeDto arg) { QrCodeBase64 = arg.QrCode; await InvokeAsync(() => StateHasChanged()); }
public async Task QrCodeWebhook(QrCodeDto qrCode) => await _webhookHub.Clients.All.SendAsync("QrCode", qrCode);