private async void GetCoinsDetail(HttpClient client, Array coins) { foreach (Coins coin in coins) { string response = await client.GetStringAsync(GetCoinURL(coin)); // json 데이터 가져오기 var data = JsonConvert.DeserializeObject <Rootobject>(response); data.Coin = coin; if (Price.Contains(data)) { Price[Price.IndexOf(data)] = data; } else { Price.Add(data); } if (!initFirst && coin == Coins.btc_krw) { SelectedCoin = CoinNameDictionary[coin]; BuyingLast = data.last; SellLast = data.last; initFirst = true; } } }
public void HandleOKClicked(object sender, System.EventArgs e) { if (_Item != null) { if (String.IsNullOrEmpty(Description) || String.IsNullOrWhiteSpace(Description)) { DisplayAlert("Error", "Item description must be entered.", "OK"); return; } if (Price.Contains(",")) { Price = Price.Replace(',', '.'); } decimal decResult; if (Decimal.TryParse(Price, out decResult)) { _Item.Price = Convert.ToDecimal(Price, new CultureInfo("en-US")); } else { _Item.Price = 0; } _Item.Description = Description; _Item.IsImportant = IsImportant; if (IsEditing) { ItemUpdated(_Item, EventArgs.Empty); } else { if (ListExistingItems.FirstOrDefault(x => x.Description == Description) == null) { ItemAdded(_Item, EventArgs.Empty); } else { DisplayAlert("Error", "You have already added an item with this name.", "OK"); return; } } Navigation.PopModalAsync(); } }
internal void Execute_EnterKeyPadNumberCommand(object parameter) { //Call methods or execute the command if ((string)parameter == ".") { if (!Price.Contains(".")) { Price += (string)parameter; } } else if ((string)parameter == "C") { Price = "0"; } else { Price += (string)parameter; } }
private bool IsFormComplete() { if ((!string.IsNullOrEmpty(Title)) && (!string.IsNullOrEmpty(Director)) && (!string.IsNullOrEmpty(Year)) && (!string.IsNullOrEmpty(Description)) && IsFileSelected()) { // Validate form values if (Year.Contains("-")) { SetMessage("Year is invalid.", ERROR_COLOR); return(false); } if (!Int32.TryParse(Year, out _yearInt)) { SetMessage("Year is invalid.", ERROR_COLOR); return(false); } if ((_yearInt < 1888) || (_yearInt > DateTime.Now.Year)) { SetMessage("We only rent movies that are currently released. Please check the date.", ERROR_COLOR); return(false); } if (Price.Contains("-")) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } if (!(Price.Length == 4)) { SetMessage("Price must be in format \"x.xx\".", ERROR_COLOR); return(false); } if (!Price.Contains(".") || !Price.Substring(1, 1).Contains(".")) { SetMessage("Price must be in format \"x.xx\".", ERROR_COLOR); return(false); } if (!Decimal.TryParse(Price, out _priceDecimal)) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } if (!(_priceDecimal > 0)) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } return(true); } else { SetMessage(ERROR, ERROR_COLOR); return(false); } }