private QRCodeImage GenerateCode(EventTicket _ticket, int count, string G_ID, int bridgingID, string EventID) { string ImageName = "Dummy"; //store New image to database QRCodeImage img = new QRCodeImage(); QRCodeImage qrcode = new QRCodeImage(); img.Name = ImageName; img.ticket_ID = bridgingID; img.EntranceTime = DateTime.Now; img.Checked_in = 0; img.Credit = _ticket._Credit; img.Location = "Dummy"; FileUploadClient fuc = new FileUploadClient(); int intQRCodeID = fuc.saveQRCodeImage(img); if (intQRCodeID != 0) { //create QR Code Image string QRCodeCotntent = Convert.ToString(intQRCodeID); var writer = new BarcodeWriter(); writer.Format = BarcodeFormat.QR_CODE; //populate code with GuestID var result = writer.Write(QRCodeCotntent); string path = Server.MapPath("~/Events/" + _ticket._EventID + "/QR_Codes/" + bridgingID + "_" + G_ID + "_QRImage.jpg"); ImageName = bridgingID + "_" + G_ID + "_QRImage.jpg"; var barcodeBitmap = new Bitmap(result); using (MemoryStream memory = new MemoryStream()) { using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite)) { barcodeBitmap.Save(memory, ImageFormat.Png); byte[] bytes = memory.ToArray(); fs.Write(bytes, 0, bytes.Length); } } //UPdate Last Added QRCode Image qrcode.Name = ImageName; qrcode.Location = path; qrcode.EntranceTime = DateTime.Now; bool isUpdated = fuc.UpdateQRCode(qrcode, Convert.ToString(intQRCodeID)); if (isUpdated == true) { //Alert is created } } return(qrcode); }