public IActionResult Download(int id) { Artworks artwork = artworkRepository.GetArtworkById(id); byte[] file = GenerateBarCode.GenerateQr(artwork.AccessionNumber.ToString()); ImageConverter converte = new ImageConverter(); string contentType = "application/png"; return(File(file, contentType, "image.png")); }
public IActionResult Post(Book book) { int number = book.Quantity; string oldBarCode = _context.Books.Where(x => x.TitleID == book.TitleID).Select(x => x.BarCode).LastOrDefault(); string[] getBarCode = GenerateBarCode.Generate(oldBarCode, book.TitleID, book.Type); string barCodeKey = getBarCode[0]; string barCodeID = getBarCode[1]; for (int i = 1; i <= number; i++) // sinh ra barcode tiếp theo { barCodeID = (int.Parse(barCodeID) + 1).ToString(); Book b = new Book(book.Type, book.Page, book.Status, book.ShelveID, book.TitleID); b.BarCode = GenerateBarCode.CustomBarCodeID(barCodeKey, barCodeID); _context.Add(b); _context.SaveChanges(); } return(NoContent()); }