Example #1
0
        public IHttpActionResult Add(Supplier supplier)
        {
            SupplierResponse response = new SupplierResponse();

            try
            {
                Supplier supplierSaved = supplierBL.InsertSupplier(supplier);
                response.Supplier = supplierSaved;
                response.Success  = true;
            }
            catch (SupplierException ex)
            {
                response.ErrorCode    = ex.Error;
                response.ErrorMessage = "Error. " + ex.Error.ToString();
                response.Supplier     = null;
                response.Success      = false;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.Supplier     = null;
                response.Success      = false;
            }
            return(Ok(response));
        }
Example #2
0
        private static void MigrateSuppliers()
        {
            List <string>   exceptions = new List <string>();
            List <Supplier> suppliers  = SupplierOld.GetSuppliers();
            SupplierBL      supplierBL = new SupplierBL(connectionString);

            foreach (Supplier supplier in suppliers)
            {
                try
                {
                    supplierBL.InsertSupplier(supplier);
                }
                catch (Exception ex)
                {
                    exceptions.Add(supplier.Name + ". Error " + ex.Message);
                }
            }
            foreach (string ex in exceptions)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }