示例#1
0
        public void ValueObjectWithCollectionField()
        {
            var wallet1 = new CoinWallet(new [] { new Coin(Coin.Value.TwoEuros), new Coin(Coin.Value.TenCents), new Coin(Coin.Value.FiftyCents) });
            var wallet2 = new CoinWallet(new [] { new Coin(Coin.Value.TwoEuros), new Coin(Coin.Value.TenCents), new Coin(Coin.Value.FiftyCents) });

            CheckAreEqual(wallet1, wallet2);
        }
示例#2
0
 public Guid Post([FromBody] CoinWallet wallet)
 {
     //create wallet
     if (GuidService.GuidInstance.WalletExists(wallet.WalletId) || wallet.WalletId == Guid.Empty)
     {
         var a = _walletService.CreateNewWallet(wallet);
         return(a);
     }
     return(Guid.Empty);
 }
示例#3
0
 public System.Guid CreateNewWallet(CoinWallet wallet)
 {
     if (GuidService.GuidInstance.WalletExists(wallet.WalletId))
     {
         return(System.Guid.Empty);
     }
     wallet.WalletId = GuidService.GuidInstance.SupplyGuid(wallet);
     _context.Wallets.Add(wallet);
     _context.SaveChanges();
     return(wallet.WalletId);
 }
示例#4
0
        public System.Guid SupplyGuid(CoinWallet wallet)
        {
            if (_existingWallets.ContainsValue(wallet))
            {
                return(System.Guid.Empty);
            }
            var a = System.Guid.NewGuid();

            _existingWallets.Add(a, wallet);
            return(a);
        }
示例#5
0
        //Produccion
        //static string apiBaseUrl = "http://tacscripto.azurewebsites.net/api/";

        public UserWallet GetWallet(string token)
        {
            var        url    = apiBaseUrl + "user/" + "wallets";
            HttpClient client = CreateClient(url);

            client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
            HttpResponseMessage response = client.GetAsync(client.BaseAddress).Result;

            string jsonResponse = response.Content.ReadAsStringAsync().Result;

            UserWallet userWallet = new UserWallet();

            userWallet.coinWallets = new List <CoinWallet>();
            if (jsonResponse != "")
            {
                foreach (var jarray in JArray.Parse(jsonResponse))
                {
                    CoinWallet coinWallet = jarray.SelectToken("Result").ToObject <CoinWallet>();
                    userWallet.coinWallets.Add(coinWallet);
                }
            }
            return(userWallet);
        }