Ejemplo n.º 1
0
        public async Task <bool> AddStocksAsync()
        {
            IAddStock stock =
                ServiceProxy.Create <IAddStock>(new Uri("fabric:/TSEIS/OwnerControl"), new ServicePartitionKey(0));

            var x = await stock.GetAllAsync();

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <bool> BuyExactStockAsync(Stock stock)
        {
            var sst = stock;

            IAddStock scproxy =
                ServiceProxy.Create <IAddStock>(new Uri("fabric:/TSEIS/OwnerControl"), new ServicePartitionKey(0));

            var success = await scproxy.UpdateStockAsync(stock);



            return(await Task.FromResult(success));
        }
Ejemplo n.º 3
0
        public async Task <bool> BuyStockAsync()
        {
            //get list of stocks from ownercontrol
            IAddStock stock =
                ServiceProxy.Create <IAddStock>(new Uri("fabric:/TSEIS/OwnerControl"), new ServicePartitionKey(0));

            var x = await stock.AddStockAsync();

            ServiceEventSource.Current.ServiceMessage(this.Context, "From Requester: List length: {0}", x.Count.ToString());

            //select one to buy
            var tempstock = new Stock()
            {
            };


            Random r    = new Random();
            var    rand = x[r.Next(x.Count)];

            tempstock.name  = rand.name;
            tempstock.value = rand.value;
            tempstock.owner = "New John";
            tempstock.id    = rand.id;


            //call boker to buy chosen stock
            IBuyExactStock buyxstock = ServiceProxy.Create <IBuyExactStock>(new Uri("fabric:/TSEIS/Broker"));

            var success = await buyxstock.BuyExactStockAsync(tempstock);

            ServiceEventSource.Current.ServiceMessage(this.Context, "From Requester - Succes buying this stock: {0}", tempstock.name);



            //call tobintaxer to calculate tax
            ICalcTax calcTaxClient = ServiceProxy.Create <ICalcTax>(new Uri("fabric:/TSEIS/TobinTaxer"));

            var requesterPrice = await calcTaxClient.CalcTaxAsync(tempstock.value);

            ServiceEventSource.Current.ServiceMessage(this.Context, "From Requester - Price paid: {0}", requesterPrice.ToString());


            return(true);
        }