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; } }
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); }); }
private async Task AddCourseAsync() { if (!ValidationHelper.IsFormValid(CourseModel, _page)) { return; } if (string.IsNullOrWhiteSpace(CourseModel.Id)) { await CourseDataStore.AddItemAsync(CourseModel); } else { await CourseDataStore.UpdateItemAsync(CourseModel); } }
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; } }
public CourseViewModel(CourseDataStore service) { _service = service; CoursesTableTitle = Properties.Strings.CoursesTableTitle; RatesTitle = Properties.Strings.RatesTitle; }