예제 #1
0
        public int updateCustomerBalance(Customer customer)
        {
            SSGetService getService = new SSGetService();
            SSAddService addService = new SSAddService();

            Customer existingCustomer = getService.getCustomerById(customer.id);

            if (existingCustomer.name != null)
            {
                using (SqlCommand command = new SqlCommand("UPDATE ss_customers SET account_balance=@balance, last_modified_date=getdate() WHERE id=" + existingCustomer.id + ""))
                {
                    command.Parameters.AddWithValue("@balance", customer.account_balance);
                    int response = service.execute(command);
                    if (response > 0)
                    {
                        addService.addLog(new Log()
                        {
                            type        = "Updated customer balance",
                            statement   = command.CommandText,
                            description = "Updated [" + existingCustomer.id + "] Customer",
                        });
                    }
                    return(response);
                }
            }
            else
            {
                return(-404);
            }
        }