コード例 #1
0
        public IHttpActionResult Add(SaleCustomer saleCustomer)
        {
            SaleCustomerResponse response = new SaleCustomerResponse();

            try
            {
                SaleCustomer saleCustomerSaved = saleCustomerBL.InsertSaleCustomer(saleCustomer);
                response.SaleCustomer = saleCustomerSaved;
                response.Success      = true;
            }
            catch (SaleCustomerException ex)
            {
                response.ErrorCode    = ex.Error;
                response.ErrorMessage = "Error. " + ex.Error.ToString();
                response.SaleCustomer = null;
                response.Success      = false;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.SaleCustomer = null;
                response.Success      = false;
            }
            return(Ok(response));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: windygu/CCSys
        private static void MigrateSaleCustomers()
        {
            List <string>       exceptions = new List <string>();
            List <SaleCustomer> customers  = SaleCustomerOld.GetSaleCustomer();
            SaleCustomerBL      customerBL = new SaleCustomerBL(connectionString);

            foreach (SaleCustomer customer in customers)
            {
                try
                {
                    customerBL.InsertSaleCustomer(customer);
                }
                catch (Exception ex)
                {
                    exceptions.Add(customer.Name + ". Error " + ex.Message);
                }
            }
            foreach (string ex in exceptions)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }