Exemplo n.º 1
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Courses.Clear();
                var items = await CourseDataStore.GetItemsAsync(true);

                if (!string.IsNullOrWhiteSpace(SearchPararmeter))
                {
                    items = items.Where(c => c.Name.ToLower().Contains(SearchPararmeter.ToLower()));
                }

                foreach (var item in items)
                {
                    Courses.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        public ItemsViewModel()
        {
            Title            = "Browse";
            Items            = new ObservableCollection <CourseModel>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <CourseDetails, CourseModel>(this, "CourseSaved", async(obj, item) =>
            {
                var newItem = item as CourseModel;
                Items.Add(newItem);
                await CourseDataStore.AddItemAsync(newItem);
            });
        }
Exemplo n.º 3
0
        private async Task AddCourseAsync()
        {
            if (!ValidationHelper.IsFormValid(CourseModel, _page))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(CourseModel.Id))
            {
                await CourseDataStore.AddItemAsync(CourseModel);
            }
            else
            {
                await CourseDataStore.UpdateItemAsync(CourseModel);
            }
        }
Exemplo n.º 4
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Items.Clear();
                var items = await CourseDataStore.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 5
0
 public CourseViewModel(CourseDataStore service)
 {
     _service          = service;
     CoursesTableTitle = Properties.Strings.CoursesTableTitle;
     RatesTitle        = Properties.Strings.RatesTitle;
 }