public async Task <IActionResult> Claim(int promotionId) { string userName = HttpContext.Session.GetString("username"); var customerProfile = (await _customerProfileService.CustomerProfile(userName)); var customerProfileId = customerProfile.CustomerProfileId; var customerEmailAddr = customerProfile.CustomerEmail; Claim claim = new Claim { PromotionId = promotionId, CustomerProfileId = customerProfileId }; var result = await _claimService.ClaimAsync(claim); if (result != null) { //Claim details int claimId = result.ClaimId; ClaimWithPromotionAndShopInfo cwpasi = await _claimService.RetrieveClaimWithPromotionAndShopInfoByClaimIdAsync(claimId); //QRCode string txtQrCode = $"ClaimId_{claimId}_ShopProfileId_{cwpasi.PromotionDto.ShopProfileId}_PromotionId_{cwpasi.PromotionDto.PromotionId}"; QRCodeGenerator qrCodeGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrCodeGenerator.CreateQrCode(txtQrCode, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeImage = qrCode.GetGraphic(20); byte[] qrBytes = await BitmapToBytes(qrCodeImage); string qrCodeString = Convert.ToBase64String(qrBytes); /*mailkit*/ var emailAddr = new Common.DBTableModelsService.EmailService.EmailAddress { Address = customerEmailAddr, Name = userName }; var emailMessage = new Common.DBTableModelsService.EmailService.EmailMessage { FromAddresses = new List <Common.DBTableModelsService.EmailService.EmailAddress> { emailAddr }, ToAddresses = new List <Common.DBTableModelsService.EmailService.EmailAddress> { emailAddr }, Content = $@" <div style=""margin - left:0; ""> <img src=""data:image/png;base64,{qrCodeString}"" height=""300"" width=""300"" /> </div> <div> <br /><b>Shop:</b>{cwpasi.ShopProfileDto.ShopName} <br /><b>Promotion Title:</b>{cwpasi.PromotionDto.Header} <br /><b>Promotion Description:</b>{cwpasi.PromotionDto.Description} <br /><b>Promotion Start Date:</b>{cwpasi.PromotionDto.StartDate.ToString("yyyy-MM-dd")} <br /><b>Promotion End Date:</b>{cwpasi.PromotionDto.EndDate.ToString("yyyy-MM-dd")} </div> ", Subject = "PromotionsSG Claim Voucher" }; var emailResult = await _notificationService.SendEmailAsync(emailMessage); return(emailResult ? new JsonResult(result) : new JsonResult(null)); } return(new JsonResult(null)); }