private async Task UpdateProfileAsync() { _model.SetActivityResource(false, true); if (Validate()) { List <Meta> metaList = new List <Meta>(); metaList.Add(_metaPivotService.AddMeta(_model.CountryName, MetaConstants.COUNTRY, MetaConstants.COUNTRY, MetaConstants.LABEL)); metaList.Add(_metaPivotService.AddMeta(_model.Address, MetaConstants.ADDRESS, MetaConstants.ADDRESS, MetaConstants.LABEL)); metaList.Add(_metaPivotService.AddMeta(_model.CityName, MetaConstants.CITY, MetaConstants.CITY, MetaConstants.LABEL)); metaList.Add(_metaPivotService.AddMeta(_model.StateName, MetaConstants.STATE, MetaConstants.STATE, MetaConstants.LABEL)); metaList.Add(_metaPivotService.AddMeta(_model.PostalCode, MetaConstants.POSTAL_CODE, MetaConstants.POSTAL_CODE, MetaConstants.LABEL)); var response = await _metaPivotService.SaveMetaAsync(metaList); _model.SetActivityResource(); if (response == HttpConstants.SUCCESS) { _model.UserMeta = null; await Navigation.PopAsync(true); } _model.SetActivityResource(showError: true, errorMessage: response == HttpConstants.SUCCESS ? TextResources.MessageUserDetailSaveSuccessful : TextResources.MessageSomethingWentWrong); } }
private async Task NextStepAsync() { var _metas = new List <Meta>(); _model.SetActivityResource(false, true, busyMessage: TextResources.ProcessingPleaseWait); if (Validate()) { _metas.Add(_metaPivotService.AddMeta(_model.CountryName, MetaConstants.COUNTRY, MetaConstants.COUNTRY, MetaConstants.LABEL)); _metas.Add(_metaPivotService.AddMeta(_model.Address, MetaConstants.ADDRESS, MetaConstants.ADDRESS, MetaConstants.LABEL)); _metas.Add(_metaPivotService.AddMeta(_model.CityName, MetaConstants.CITY, MetaConstants.CITY, MetaConstants.LABEL)); _metas.Add(_metaPivotService.AddMeta(_model.StateName, MetaConstants.STATE, MetaConstants.STATE, MetaConstants.LABEL)); _metas.Add(_metaPivotService.AddMeta(_model.PostalCode, MetaConstants.POSTAL_CODE, MetaConstants.POSTAL_CODE, MetaConstants.LABEL)); foreach (var meta in _metas) { _user.UserMetas.Add(meta); } if (await _metaPivotService.SaveMetaStep2Async(_metas)) { App.CurrentApp.MainPage = new UploadPhotoPage(_user); } else { _model.SetActivityResource(showError: true, errorMessage: _helper.ReturnMessage(_metaPivotService.Message)); } } }
private async Task NextStepAsync() { _model.SetActivityResource(false, true, busyMessage: TextResources.ProcessingPleaseWait); if (Validate()) { _user.UserMetas.Add(_metaPivotService.AddMeta(_model.AgeValue.ToString(), MetaConstants.AGE, MetaConstants.AGE, MetaConstants.LABEL)); var tracker = _trackerPivotService.AddTracker(TrackerConstants.CURRENT_WEIGHT, _model.CurrentWeightValue.ToString()); tracker.RevisionNumber = revisionNumber; _user.UserTrackers.Add(tracker); tracker = _trackerPivotService.AddTracker(TrackerConstants.CURRENT_WEIGHT_UI, _model.CurrentWeightValue.ToString()); tracker.RevisionNumber = revisionNumber; _user.UserTrackers.Add(tracker); tracker = _trackerPivotService.AddTracker(TrackerConstants.WEIGHT_VOLUME_TYPE, App.Configuration.AppConfig.DefaultWeightVolume); tracker.RevisionNumber = revisionNumber; _user.UserTrackers.Add(tracker); _user.UserMetas.Add(_metaPivotService.AddMeta(_model.WeightLossGoalValue.ToString(), MetaConstants.WEIGHT_LOSS_GOAL, MetaConstants.WEIGHT_LOSS_GOAL, MetaConstants.LABEL)); _user.UserMetas.Add(_metaPivotService.AddMeta(_model.WeightLossGoalValue.ToString(), MetaConstants.WEIGHT_LOSS_GOAL_UI, MetaConstants.WEIGHT_LOSS_GOAL_UI, MetaConstants.LABEL)); _user.UserMetas.Add(_metaPivotService.AddMeta(App.Configuration.AppConfig.DefaultWeightVolume, MetaConstants.WEIGHT_VOLUME_TYPE, MetaConstants.WEIGHT_VOLUME_TYPE, MetaConstants.LABEL)); var response = await _metaPivotService.SaveMetaStep2Async(_user.UserMetas); if (response) { var result = await _trackerPivotService.SaveTrackerStep3Async(_user.UserTrackers); if (result) { App.CurrentApp.MainPage = new AddressPage(_user); } else { _model.SetActivityResource(showError: true, errorMessage: _helper.ReturnMessage(_trackerPivotService.Message)); } } else { _model.SetActivityResource(showError: true, errorMessage: _helper.ReturnMessage(_metaPivotService.Message)); } } }
private async void UploadPhoto(Plugin.Media.Abstractions.MediaFile mediaFile) { if (mediaFile != null) { await Task.Run(() => { _model.SetActivityResource(false, true); }); if (await _media.UploadPhotoAsync(mediaFile)) { if (!string.IsNullOrEmpty(_media.FileName)) { var profileImage = _metaPivotService.AddMeta(_media.FileName, MetaConstants.PROFILE_PHOTO.ToCapital(), MetaConstants.PROFILE_PHOTO, MetaConstants.PROFILE_PHOTO); var response = await _metaPivotService.SaveMetaAsync(profileImage); if (response != null && response.Contains(HttpConstants.SUCCESS)) { _model.User.ProfileImage = _media.FileName; App.CurrentUser.UserInfo = _model.User; _model.ProfileImagePath = _model.User.ProfileImage; _model.SetActivityResource(showMessage: true, message: TextResources.ChangeProfilePhoto + " " + TextResources.Change + " " + TextResources.Success); return; } } } } _model.SetActivityResource(showError: true, errorMessage: _media.Message); }
private async void SaveGender() { if (IsGenderRequired) { await _metaPivotService.SaveMetaAsync(new List <Meta>() { _metaPivotService.AddMeta(GenderSelected.ToString(), MetaConstants.GENDER, MetaConstants.GENDER, MetaConstants.LABEL) }); } }
private async void ChangeProfilePhoto(object sender, EventArgs args) { var result = await DisplayActionSheet(TextResources.ChooseOption, TextResources.Cancel, null, new string[] { TextResources.PickFromGallery, TextResources.TakeFromCamera }); if (result != null) { if (result == "Cancel") { return; } if (result == TextResources.PickFromGallery) { _media.Refresh(); var mediaFile = await _media.PickPhotoAsync(); if (mediaFile == null) { _model.SetActivityResource(showError: true, errorMessage: _media.Message); return; } await Task.Run(() => { _model.SetActivityResource(false, true); }); var response = await _media.UploadPhotoAsync(mediaFile); if (!response) { _model.SetActivityResource(true, false, showError: true, errorMessage: _media.Message); return; } } else if (result == TextResources.TakeFromCamera) { _media.Refresh(); var mediaFile = await _media.TakePhotoAsync(); if (mediaFile == null) { _model.SetActivityResource(showError: true, errorMessage: _media.Message); return; } await Task.Run(() => { _model.SetActivityResource(false, true); }); var response = await _media.UploadPhotoAsync(mediaFile); if (!response) { _model.SetActivityResource(true, false, showError: true, errorMessage: _media.Message); return; } } _model.SetActivityResource(); if (!string.IsNullOrEmpty(_media.FileName)) { var profileImage = _metaPivotService.AddMeta(_media.FileName, MetaConstants.PROFILE_PHOTO.ToCapital(), MetaConstants.PROFILE_PHOTO, MetaConstants.PROFILE_PHOTO); var response = await _metaPivotService.SaveMetaAsync(profileImage); if (response != null && response.Contains(HttpConstants.SUCCESS)) { _model.User.ProfileImage = _media.FileName; App.CurrentUser.UserInfo = _model.User; _model.ProfileImagePath = _model.User.ProfileImage; _model.SetActivityResource(showMessage: true, message: TextResources.ChangeProfilePhoto + " " + TextResources.Change + " " + TextResources.Success); } } else { _model.SetActivityResource(showError: true, errorMessage: _media.Message); } } }