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); }
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); }
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); }
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); }
//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); }