예제 #1
0
        //public HttpReq(String type, String url)
        //{
        //    if(type == "GET")
        //    {
        //        get(url);
        //    }
        //}

        public ArrayList get(String url)
        {
            ArrayList al             = new ArrayList();
            var       httpWebRequest = WebRequest.Create(url);
            string    text;

            httpWebRequest.ContentType = "application/json; charset=utf-8";
            var response = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                text = sr.ReadToEnd();
            }

            JToken  root  = JObject.Parse(text);
            JToken  all   = root["GetAllAccountsResult"];
            Account deser = JsonConvert.DeserializeObject <Account>(ToString());

            System.Diagnostics.Debug.WriteLine(deser.ToString());

            Account a = new Account();

            JsonConvert.DeserializeObject <Account.GetAccountResult>(text);
            return(null);
        }
예제 #2
0
        static void Main(string[] args)
        {
            int    UserId;
            int    Pin;
            int    Counter = 0;
            double amount;

            Console.WriteLine("Welcome");
            do
            {
                Console.Write("Enter Account Number: ");
                UserId = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter Pin: ");
                Pin = Convert.ToInt32(Console.ReadLine());
                if (CheckCredentials(UserId, Pin))
                {
                    Success = true;
                    break;
                }
                else
                {
                    Counter++;
                }
            } while (Counter <= 3);

            if (Success)
            {
                Account acc = new Account(UserId, Pin, balance);
                Console.WriteLine("Login Successful");
                Boolean exit = false;
                do
                {
                    Console.WriteLine(acc.ToString());
                    Console.WriteLine("Choose one of the following options: D-Depoist, W-Withdraw, U-Update Pin, T- Transactions or E-Exit");
                    char option = Convert.ToChar(Console.ReadLine());

                    switch (char.ToUpper(option))
                    {
                    case 'E':
                        exit = true;
                        break;

                    case 'W': Console.WriteLine("Enter amount to withdraw: ");
                        amount = Convert.ToDouble(Console.ReadLine());
                        acc.Withdraw(amount);
                        WriteTransaction('W', amount, acc.AccountNumber);
                        break;

                    case 'D':
                        Console.WriteLine("Enter amount to deposit: ");
                        amount = Convert.ToDouble(Console.ReadLine());
                        acc.Deposit(amount);
                        WriteTransaction('D', amount, acc.AccountNumber);
                        break;

                    case 'U':
                        Console.WriteLine("Enter new pin:");
                        acc.UpdatePin(Convert.ToInt32(Console.ReadLine()));
                        break;

                    case 'T':
                        PrintTransactions(acc.AccountNumber);
                        break;

                    default:
                        Console.WriteLine("Invalid option, try again!");
                        break;
                    }
                } while (!exit);
                UpdateServer(acc);
                Console.WriteLine("Server updated\r\nSession Closed");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Login Unsuccessful");
            }
        }