'use strict';

/* Controllers */

function PaymentCtl($scope, $routeParams) {
    $scope.paymentid = $routeParams.paymentid
}

function DashBoardCtrl($scope, $http) {
    $scope.msg = "dashboard"
}

function LoginCtrl($scope, $http, $location) {
    $scope.msg = ""
    $scope.tryLogin = function (username, password) {
        $scope.msg = "Working"
        $http.post(
            "https://us.bittoll.com/alias",
            {
                "aliasName": username,
                "aliasPassword": password,
            }
        ).
        success(function(data, status, haders, config) {
            if (data["error_code"] !== "0") {
                console.log("error")
                console.log(data)
                $scope.msg = "Error Logging In"
                return
            }
            delete(data["error_code"])
            $scope.msg = "Success"
            $scope.login = data
            $location.path("/dashboard") 
        }).
        error(function(data, status, headers, config) {
            console.log("error")
            console.log(data)
            console.log(status)
            $scope.msg = "Error communicating with server"
        })
    }
    $scope.register = function (username, password) {
        $scope.msg = "Working"

        $http.post("https://us.bittoll.com/register","{}").
        success(function(data, status, headers, config) {
            if (data["error_code"] !== "0") {
                console.log("error")
                console.log(data)
                $scope.msg = "Error Registering"
                return
            }
            var login = data
            delete(login["error_code"])
            $scope.msg = "Working..."

            $http.post(
                "https://us.bittoll.com/setalias",
                makeDict(login,
                    {
                        "aliasName":username,
                        "aliasPassword":password,
                    }
                )
            ).
            success(function(data, status, headers, config) {
                if (data["error_code"] !== "0") {
                    $scope.login = undefined
                    console.log("succ err")
                    $scope.msg = "Error registering"
                    return
                }
                $scope.login = login
                $scope.msg = "Success"
                $location.path("/dashboard")
            }).
            error(function(data, status, headers, config) {
                $scope.login = undefined
                $scope.msg = "Error Communicating with server"
                console.log(data)
                console.log("succ err")
            })
        }).
        error(function(data, status, headers, config) {
            console.log("error")
            console.log(data)
            $scope.msg = "Error Communicating with server"
        })
    }
}


@@ -67,16 +67,23 @@
 teParams
+, $http
 ) %7B%0A    
@@ -124,16 +124,458 @@
 ymentid%0A
+    var login = %7B%7D%0A    $scope.accept = function () %7B%0A        console.log(%22Accepted%22)%0A    %7D%0A    $scope.reject = function () %7B%0A        console.log(%22Rejected%22)%0A    %7D%0A%0A    $http.post(%0A        %22https://us.bittoll.com/requestinfo%22,%0A        makeDict(login,%0A            %7B%0A                %22paymentid%22: $scope.paymentid%0A            %7D%0A        )%0A    ).%0A    success(function (data, status, headers, config) %7B%0A        $scope.amount = data%5B%22amount%22%5D%0A    %7D)%0A
 %7D%0A%0Afunct

Add basic payment page mock out