Exemplo n.º 1
0
        public Int32 Inserta(VendorBE pItem, List <VendorAddressBE> pListaVendorAddress, List <VendorContactBE> pListaVendorContact, List <VendorClassificationBE> pListaVendorClassification)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    int IdVendor = 0;
                    IdVendor = Vendor.Inserta(pItem);

                    foreach (var item in pListaVendorAddress)
                    {
                        item.IdVendor = IdVendor;
                        VendorAddress.Inserta(item);
                    }

                    foreach (var item in pListaVendorContact)
                    {
                        item.IdVendor = IdVendor;
                        VendorContact.Inserta(item);
                    }

                    foreach (var item in pListaVendorClassification)
                    {
                        item.IdVendor = IdVendor;
                        VendorClassification.Inserta(item);
                    }


                    ts.Complete();

                    return(IdVendor);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }