I have a form that receives and inserts into a database input of a product in this case a batch of booklet from a supplier. The product fields are batch number, supplier name, Serial Numbers, Quantity of booklets Received(PCs inside a batch).
 
I am able to insert the input into table booklets but I also want to generate Barcodes based on the number of quantity of booklets received and store it in a second table called Barcode table that captures the details of a single booklet. e.g If I received 10 booklets, I want to generate 10 Barcodes and store in a second table. I am able to generate Barcode for a single booklet but in this case I want to generate multiple number of Barcodes based on the number of Quantity of booklets Received. How do I loop through the quantity received number generate these multiple Barcodes and store in table Barcode ?
 
My create function inside a Controller to insert data into both tables at the same time.
- [HttpPost]  
 -  [ValidateAntiForgeryToken]   
 - public ActionResult Create(bts_receivebookletfromsupplier bts_receivebookletfromsupplier)  
 -  {   
 -   
 -  Barcodecs objbar = new Barcodecs();   
 -       Barcode barcode = new Barcode();   
 -       barcode.Barcode1 = objbar.generateBarcode();   
 -       barcode.Name = bts_receivebookletfromsupplier.BatchNo + "-" + DateTime.Now.ToString();   
 -       barcode.Description = DateTime.Now.ToString();  
 -       barcode.BarcodeImage = objbar.getBarcodeImage(objbar.generateBarcode(), barcode.Name);  
 -      if (ModelState.IsValid) {   
 -          db.bts_receivebookletfromsupplier.Add(bts_receivebookletfromsupplier);  
 -             
 -            db.Barcodes.Add(barcode);   
 -            db.SaveChanges();   
 -          TempData["Success"] = bts_receivebookletfromsupplier.QtyReceived + " Booklets  successfully recieved";  
 -          return RedirectToAction("Index");   
 -          } else {   
 -            ModelState.AddModelError("", "Error submiting. Submission Aborted");   
 -         }  
 -         return View(bts_receivebookletfromsupplier);   
 -       }   
 - }