Ejemplo n.º 1
0
        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));
                }
            }
        }