public MainViewModel()
        {
            Quotes = new ObservableCollection <QuoteViewModel>(QuoteManager.Load()
                                                               .Select(q => new QuoteViewModel(q)));

            SelectedQuote = Quotes.FirstOrDefault();
        }
Esempio n. 2
0
        public MainViewModel()
        {
            Quotes = new ObservableCollection <QuoteViewModel>(QuoteManager.Load()
                                                               .Select(q => new QuoteViewModel(q)));

            SelectedQuote   = Quotes.FirstOrDefault();
            AddQuote        = new Command(async() => await OnAddQuote());
            DeleteQuote     = new Command <QuoteViewModel>(async vm => await OnDeleteQuote(vm));
            EditQuote       = new Command <QuoteViewModel>(async vm => await OnEditQuote(vm));
            ShowQuoteDetail = new Command <QuoteViewModel>(async vm => await OnShowQuoteDetails(vm));
        }
Esempio n. 3
0
        public async Task OnAddQuote()
        {
            var newQuote = new QuoteViewModel();

            Quotes.Add(newQuote);
            SelectedQuote = newQuote;

            if (!DependencyService.Get <INavigationService>().CanGoBack)
            {
                await DependencyService.Get <INavigationService>()
                .NavigateAsync(AppPages.Edit, newQuote);
            }
        }
        private async Task OnAddQuote()
        {
            var newQuote = new QuoteViewModel();

            Quotes.Add(newQuote);
            SelectedQuote = newQuote;

            if (!serviceLocator.Get <INavigationService>().CanGoBack)
            {
                await serviceLocator.Get <INavigationService>()
                .NavigateAsync(AppPages.Edit, newQuote);
            }
        }
Esempio n. 5
0
        public async Task OnDeleteQuote(QuoteViewModel quote)
        {
            bool result = await DependencyService.Get <IMessageVisualizerService>()
                          .ShowMessage("Are you sure?",
                                       "Are you sure you want to delete this quote from " + quote.Author + "?",
                                       "Yes", "No");

            if (result == true)
            {
                int pos = Quotes.IndexOf(quote);
                Quotes.Remove(quote);
                if (SelectedQuote == quote)
                {
                    if (pos > Quotes.Count - 1)
                    {
                        pos = Quotes.Count - 1;
                    }
                    SelectedQuote = Quotes[pos];
                }
            }
        }
Esempio n. 6
0
 public async Task OnShowQuoteDetails(QuoteViewModel quote)
 {
     SelectedQuote = quote;
     await DependencyService.Get <INavigationService>().NavigateAsync(AppPages.Detail, quote);
 }
Esempio n. 7
0
 public async Task OnEditQuote(QuoteViewModel quote)
 {
     SelectedQuote = quote;
     await DependencyService.Get <INavigationService>()
     .NavigateAsync(AppPages.Edit, quote);
 }
 private async Task OnEditQuote(QuoteViewModel quote)
 {
     SelectedQuote = quote;
     await serviceLocator.Get <INavigationService>()
     .NavigateAsync(AppPages.Edit, quote);
 }
 private async Task OnShowQuoteDetails(QuoteViewModel qvm)
 {
     SelectedQuote = qvm;
     await serviceLocator.Get <INavigationService>()
     .NavigateAsync(AppPages.Detail);
 }