コード例 #1
0
        //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
            };
        }
コード例 #2
0
        //when u select a post
        private async Task SelectPicture(PicturesViewModel post)
        {
            if (post == null)
            {
                return;
            }

            SelectedPost = null;
            await _pageService.PushAsync(new PicturesDetailPage(post));
        }
コード例 #3
0
        //deleting a picture

        private async Task DeletePicture(PicturesViewModel picturesViewModel)
        {
            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete {picturesViewModel.PictureTitle}?", "Yes", "No"))
            {
                Posts.Remove(picturesViewModel);

                PicturePost contact = await _postStore.GetPicturePost(picturesViewModel.ID);

                await _postStore.DeletePicturePost(contact);
            }
        }
コード例 #4
0
 //reset the picture category
 private async Task ResetPictureCategory(PicturesViewModel post)
 {
     post.PictureCategory = "";
 }
コード例 #5
0
 //reset the picture rating
 private async Task ResetPictureRating(PicturesViewModel post)
 {
     post.PictureRating = 0;
 }