Exemple #1
0
        public async Task <IActionResult> Post(Item item)
        {
            try
            {
                var itemResponse = await _itemService.Add(item);

                if (itemResponse == null)
                {
                    return(BadRequest());
                }
                var json           = JsonConvert.SerializeObject(itemResponse);
                var qrCodeData     = _qrCodeService.GenerateQRCode(json);
                var qrCodeImageURL = _itemService.GenerateImageURL("QRCodes", itemResponse.Id.ToString(), qrCodeData);
                return(Ok(new {
                    qrCodeUrl = qrCodeImageURL,
                    numItem = itemResponse.NumItem,
                }));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  $"Erro ao tentar adicionar este item. Erro {ex.Message}"));
            }
        }
Exemple #2
0
        public IActionResult OnGet()
        {
            var image = qrCodeService.GenerateQRCode("asd");

            return(File(image, "image/jpeg"));
        }