public wsSQLResult CreateAccount(Stream JSONdataStream)
        {
            wsSQLResult result = new wsSQLResult();

            try
            {
                StreamReader reader   = new StreamReader(JSONdataStream);
                string       JSONdata = reader.ReadToEnd();

                JavaScriptSerializer jss = new JavaScriptSerializer();

                wsAccount acc = jss.Deserialize <wsAccount>(JSONdata);
                if (acc == null)
                {
                    result.WasSuccessful = 0;
                    result.Exception     = "Unable to deserialize the JSON data.";
                    return(result);
                }

                BankDataContext dc         = new BankDataContext();
                Account         newAccount = new Account()
                {
                    balance        = acc.balance,
                    running_totals = acc.runningTotals,
                    first_name     = acc.firstName,
                    last_name      = acc.lastName,
                    address        = acc.Address,
                    postcode       = acc.postCode,
                    telephone      = acc.telePhone,
                    pin            = acc.pin
                };

                dc.Accounts.InsertOnSubmit(newAccount);
                dc.SubmitChanges();

                result.WasSuccessful = 1;
                result.Exception     = "";
                return(result);
            }
            catch (Exception ex)
            {
                result.WasSuccessful = 0;
                result.Exception     = ex.Message;
                return(result);
            }
        }
        public wsSQLResult CreateTransaction(Stream JSONdataStream)
        {
            wsSQLResult result = new wsSQLResult();

            try
            {
                StreamReader reader   = new StreamReader(JSONdataStream);
                string       JSONdata = reader.ReadToEnd();

                JavaScriptSerializer jss  = new JavaScriptSerializer();
                wsTransaction        tran = jss.Deserialize <wsTransaction>(JSONdata);
                if (tran == null)
                {
                    // Error: Couldn't deserialize our JSON string into a "wsCustomer" object.
                    result.WasSuccessful = 0;
                    result.Exception     = "Unable to deserialize the JSON data.";
                    return(result);
                }

                BankDataContext dc = new BankDataContext();

                Transaction newTransaction = new Transaction()
                {
                    amount   = tran.amount,
                    datetime = DateTime.Now,
                    acc_id   = tran.acc_id
                };

                dc.Transactions.InsertOnSubmit(newTransaction);
                dc.SubmitChanges();

                result.WasSuccessful = 1;
                result.Exception     = "";
                return(result);
            }
            catch (Exception ex)
            {
                result.WasSuccessful = 0;
                result.Exception     = ex.Message;
                return(result);
            }
        }