//constructor public PictureDetailViewModel(PicturesViewModel viewModel, IPicturePostStore pictureStore, IPageService pageService) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } _pictureStore = pictureStore; _pageService = pageService; SaveCommand = new Command(async() => await Save()); PickPictureCommand = new Command(async() => await PickPicture()); Post = new PicturePost { ID = viewModel.ID, PictureTitle = viewModel.PictureTitle, PictureCategory = viewModel.PictureCategory, PictureLocation = viewModel.PictureLocation, PictureTime = viewModel.PictureTime, PictureRating = viewModel.PictureRating, PicturePath = viewModel.PicturePath }; }
//constructor public PicturesPageViewModel(IPicturePostStore pictureStore, IPageService pageService) { _postStore = pictureStore; _pageService = pageService; LoadDataCommand = new Command(async() => await LoadData()); LoadAllPost = new Command(async() => await ReloadData()); LoadByTime = new Command(async() => LoadTime()); LoadByRating = new Command(async() => LoadRating()); LoadByBusiness = new Command(async() => LoadBusiness()); LoadByPersonal = new Command(async() => LoadPersonal()); LoadByEducational = new Command(async() => LoadEducational()); AddPictureCommand = new Command(async() => await AddPicture()); SelectPictureCommand = new Command <PicturesViewModel>(async c => await SelectPicture(c)); DeletePictureCommand = new Command <PicturesViewModel>(async c => await DeletePicture(c)); ResetPictureRatingCommand = new Command <PicturesViewModel>(async(obj) => await ResetPictureRating(obj)); ResetPictureCategoryCommand = new Command <PicturesViewModel>(async(obj) => await ResetPictureCategory(obj)); //keep track of events MessagingCenter.Subscribe <PictureDetailViewModel, PicturePost> (this, Events.PostAdded, OnPictureAdded); //keep track of events MessagingCenter.Subscribe <PictureDetailViewModel, PicturePost> (this, Events.PictureUpdated, OnPictureUpdated); }