/// <summary> /// Costruttore. /// </summary> /// <param name="db">IDataAccessDb</param> public AnteprimaSchedinaViewModel(IDataAccessDb db) { if (IsInDesignMode) { // design-mode } else { // INIT this.selectedSchedina = new Schedina(); this.selectedScommessa = new Scommessa(); this.selectedIncontro = new Incontro(); this.listScommesse = new ObservableCollection <Scommessa>(); // DB this.dataAccessDb = db; // RELAY COMMAND NavToPageCommand = new RelayCommand(InsertSchedinaCommandExecute); UpdateScommessaCommand = new RelayCommand <string>(UpdateScommessaCommandExecute); DeleteScommessaCommand = new RelayCommand <Scommessa>(DeleteScommessaCommandExecute); RemoveSelectedItemCommand = new RelayCommand(RemoveSelectedItemCommandExecute); AlreadyUpdateScommessaCommand = new RelayCommand(AlreadyUpdateScommessaCommandExecute); } }
/// <summary> /// Cancella dal DB una Scommessa di una determinata Schedina. /// </summary> private async void DeleteScommessaCommandExecute(Scommessa s) { if (s != null && s.GetType() == typeof(Scommessa)) { System.Diagnostics.Debug.WriteLine("[ANTEPRIMASCHEDINAVIEWMODEL] \t" + "Tapped DeleteScommmessaCommand: " + s.IdScommessa.ToString() + "," + s.IdMatch.ToString()); bool isDeleted = await dataAccessDb.DeleteScommessa(s); if (isDeleted) { ListScommesse.Remove(s); } else { // TODO // Notificare l'errore nella UI. } } }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { Scommessa s = value as Scommessa; // 1 X 2 if (((string)parameter) == "1X2" && (!string.IsNullOrEmpty(s.Q1) || !string.IsNullOrEmpty(s.QX) || !string.IsNullOrEmpty(s.Q2))) { System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa 1X2 Visible"); return(Visibility.Visible); } // Over/Hunder if ((string)parameter == "OverUnder" && !string.IsNullOrEmpty(s.TotalScore)) { System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa Over/Under Visible"); return(Visibility.Visible); } // Handicap if ((string)parameter == "Handicap" && !string.IsNullOrEmpty(s.HC)) { System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa Handicap Visible"); return(Visibility.Visible); } // Doppia Chance if ((string)parameter == "DoppiaChance" && (!string.IsNullOrEmpty(s.DC12) || !string.IsNullOrEmpty(s.DC1X) || !string.IsNullOrEmpty(s.DCX2))) { System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa DoppiaChance Visible"); return(Visibility.Visible); } // Home Away if ((string)parameter == "HomeAway" && (!string.IsNullOrEmpty(s.Home12) || !string.IsNullOrEmpty(s.Away12))) { System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa HomeAway Visible"); return(Visibility.Visible); } } System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToVisibilityConverter] \t" + "Scommessa " + (string)parameter + " Collapsed"); return(Visibility.Collapsed); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double opacity = 1; if (value != null) { Scommessa s = value as Scommessa; switch ((string)parameter) { case "Q1": { // Se la string non è vuota, allora è una quota giocata, quindi imposta l'opacity. if (!string.IsNullOrEmpty(s.Q1)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "Q1 opacity LOW"); } } break; case "QX": { if (!string.IsNullOrEmpty(s.QX)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "QX opacity LOW"); } } break; case "Q2": { if (!string.IsNullOrEmpty(s.Q2)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "Q2 opacity LOW"); } } break; case "HC1": { if (!string.IsNullOrEmpty(s.HC1)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "HC1 opacity LOW"); } } break; case "HCX": { if (!string.IsNullOrEmpty(s.HCX)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "HCX opacity LOW"); } } break; case "HC2": { if (!string.IsNullOrEmpty(s.HC2)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "HC2 opacity LOW"); } } break; case "OVER": { if (!string.IsNullOrEmpty(s.OVER)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "OVER opacity LOW"); } } break; case "UNDER": { if (!string.IsNullOrEmpty(s.UNDER)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "UNDER opacity LOW"); } } break; case "DC1X": { if (!string.IsNullOrEmpty(s.DC1X)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "DC1X opacity LOW"); } } break; case "DC12": { if (!string.IsNullOrEmpty(s.DC12)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "DC12 opacity LOW"); } } break; case "DCX2": { if (!string.IsNullOrEmpty(s.DCX2)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "DCX2 opacity LOW"); } } break; case "Home12": { if (!string.IsNullOrEmpty(s.Home12)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "Home12 opacity LOW"); } } break; case "Away12": { if (!string.IsNullOrEmpty(s.Away12)) { opacity = 0.3; System.Diagnostics.Debug.WriteLine("[ScommessaPropertyToOpacityConverter] \t" + "Away12 opacity LOW"); } } break; default: break; } } return(opacity); }