예제 #1
0
        /// <summary>
        /// Ajouter un furnisseur dans la table 'Supplier' et dans la table 'SitesSupplier'
        /// </summary>
        /// <param name="sup"></param>
        public static void InsertSupplier(Supplier sup, SiteSupplier ss)
        {
            SupplierDal.Insert(sup);
            ss.sup_id = SupplierDal.LoadAll().Last <Supplier>().sup_id;

            InsertSupplierSite(ss);
        }
예제 #2
0
        /// <summary>
        ///     Add a new supplier and return if successful
        /// </summary>
        /// <param name="supplier"></param>
        public void AddNewSupplier(Supplier supplier)
        {
            using (var scope = new TransactionScope())
            {
                using (var connection = Connector.GetConnection())
                {
                    var supplierDal = new SupplierDal(connection);
                    supplierDal.Insert(supplier.Name, supplier.Contact);
                    supplier.Id = supplierDal.GetLastInsertId();

                    // Exception handling
                    if (supplier.Id == null)
                    {
                        throw new ArgumentNullException(nameof(supplier.Id), "Supplier Id null after insert");
                    }
                }
                scope.Complete();
            }
        }