Ejemplo n.º 1
0
        public async Task AddImage(string plantId, PlantTaggerV1.Models.Image image)
        {
            AccessToken authToken            = getAuthToken();
            string      uri                  = Constants.PtBasedUrl + "user/plant/" + plantId + "/image";
            MultipartFormDataContent param   = new MultipartFormDataContent();
            StreamContent            content = new StreamContent(image.toStream());

            content.Headers.ContentType = new MediaTypeHeaderValue(MimeTypes.GetMimeType(image.FileName));
            param.Add(content, "img", image.FileName);
            await _requestProvider.PostAsync <BaseResult <PlantTaggerV1.Models.Image> >(uri, param, authToken.Token);
        }
        private async Task AddImageAsync()
        {
            try
            {
                PlantTaggerV1.Models.Image img = await _photoPickerService.PickPhotoAsync();

                await _plantService.AddImage(CurrentPlant.Uuid, img);
                await RefreshAsync();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + ex.Message);
                await DialogService.ShowAlertAsync(ex.Message, "Add Image Failed", "Ok");
            }
        }
Ejemplo n.º 3
0
        private async Task UpdateProfilePictureAsync()
        {
            try
            {
                PlantTaggerV1.Models.Image img = await _photoPickerService.PickPhotoAsync();

                if (img != null)
                {
                    this.CurrentUserProfile.ProfileImage = img;
                    await _userService.SaveProfileImage(img);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + ex.Message);
            }
        }
        private async Task GetPlantImagesAsync()
        {
            try
            {
                this.PlantImages = await _plantService.GetImages(this.CurrentPlant.Uuid);

                foreach (PlantTaggerV1.Models.Image plantImage in this.PlantImages)
                {
                    PlantTaggerV1.Models.Image img = await _plantService.GetImage(this.CurrentPlant.Uuid, plantImage.Uuid);

                    plantImage.Content = img.Content;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + ex.Message);
            }
        }
Ejemplo n.º 5
0
        protected async Task ChoosePhotoAsync()
        {
            PlantTaggerV1.Models.Image img = await _photoPickerService.PickPhotoAsync();

            NewPlant.ProfileImage = img;
        }