Exemple #1
0
        public static MethodResponseErrorCode UpdateCreditCard(CreditCard creditcard)
        {
            MethodResponseErrorCode response = null;
            // Update the database.
            TradingSupportClient tradingSupportClient = new TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint);

            try
            {
                lock (DataModel.SyncRoot)
                {
                    CreditCardRow row = DataModel.CreditCard.CreditCardKey.Find(creditcard.RowId);

                    if (TradingSupportWebService.ColumnChanged(row, creditcard))
                    {
                        response = tradingSupportClient.UpdateCreditCard(new CreditCard[] { creditcard });
                    }
                    else
                    {
                        response = null;
                    }
                }
            }
            catch (Exception exception)
            {
                // Any issues trying to communicate to the server are logged.
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                if (tradingSupportClient != null && tradingSupportClient.State == CommunicationState.Opened)
                {
                    tradingSupportClient.Close();
                }
            }
            return(response);
        }