コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static async Task NotifyQrCodeReceived(QrCodeDto qrCodeDto)
 => await OnQrCodeReceivedEvent?.Invoke(qrCodeDto);
コード例 #4
0
 private async Task AuthenticationBase_OnQrCodeReceivedEvent(QrCodeDto arg)
 {
     QrCodeBase64 = arg.QrCode;
     await InvokeAsync(() => StateHasChanged());
 }
コード例 #5
0
 public async Task QrCodeWebhook(QrCodeDto qrCode)
 => await _webhookHub.Clients.All.SendAsync("QrCode", qrCode);