public RestoraniViewModel() { //postavljanje komandi SearchCommand = new RelayCommand<object>(obaviSearch, mozelSearch); //lambda funkcije iz RPR da se ne prave metode za minorne stvari OpenSearchCommand = new RelayCommand<object>((object parametar) => SearchMode = true, (object parametar) => true); CloseSearchCommand = new RelayCommand<object>((object parametar) => SearchMode = false, (object parametar) => true); Restorani = new ObservableCollection<Restoran>(); RestoraniDS = new RestoranDataSource(); SearchOpcije = new SearchOpcije(); //defaultne opcije da ima nekih restorana SearchOpcije.GeoSirina = 40.7; SearchOpcije.GeoDuzina = -74; //povuci restorane i kad se obavi upit, pozovi restorani loaded RestoraniDS.dajRestoraneFourSquare(SearchOpcije,RestoraniLoaded); }
public async void dajRestoraneFourSquare(SearchOpcije so, Action callback) { Restorani = new List<Restoran>(); //povuci opcije iz json file JsonObject servicesConfig = JsonValue.Parse(File.ReadAllText("ServicesConfig.json")).GetObject(); //samo jednom ide registracija if (con == null) { con = new FourSqareConnector(servicesConfig.GetNamedObject("FourSquareApiService").GetNamedObject("options")); await con.authenticate(); } VenService = new VenusService(con.OAuthToken); await VenService.getVenus(so.GeoSirina, so.GeoDuzina); foreach(Venue v in VenService.Venues) { Restorani.Add(new Restoran(v)); } callback(); }