protected override void InitFromBundle(IMvxBundle parameters) { base.InitFromBundle(parameters); WhistleEditViewModel = new WhistleEditViewModel(); if (_messenger != null) { return; } _messenger = Mvx.Resolve <IMvxMessenger>(); }
protected async void onCreateWhistle() { IsBusy = true; var whistle = WhistleEditViewModel.GetNewWhistle(); whistle.Provider = ContextSwitchViewModel.IsProviderChecked; var result = await ServiceHandler.PostAction <CreateWhistleRequest, CreateWhistleResponse>( new CreateWhistleRequest { Whistle = whistle }, ApiAction.CREATE_WHISTLE); IsBusy = false; if (result.HasError) { _messenger.Publish(new MessageHandler(this, HomeConstants.RESULT_WHISTLE_CREATION_FAILED).WithPayload(result.Error.GetErrorMessage())); //THE following code will be removed. var lat = WhistleEditViewModel.SourcePoint.Coordinates[0]; var lng = WhistleEditViewModel.SourcePoint.Coordinates[1]; result = new ServiceResult <CreateWhistleResponse>(new CreateWhistleResponse { NewWhistle = new Whistle { }, MatchingWhisltes = new[] { new MatchingWhistle { Dis = 0, Obj = new User { Location = new CustomLocation { Coordinates = new [] { lat + 0.002, lng - 0.001 } } } }, new MatchingWhistle { Dis = 0, Obj = new User { Location = new CustomLocation { Coordinates = new [] { lat - 0.001, lng + 0.002 } } } }, } }, "will_mock_asap"); } SelectedWhistleItem = null; this.WhistleResultViewModel = new ViewModels.WhistleResultViewModel(result.Result.MatchingWhisltes); _messenger.Publish(new MessageHandler(this, HomeConstants.ACTION_SHOW_WHISTLERS)); }
private void onUserAction(string value) { switch (value) { case HomeConstants.ACTION_SHOW_WHISTLERS: /*do some backend call ????.*/ { var err = WhistleEditViewModel.IsValid(); if (err.Length == 0) { onCreateWhistle(); } else { _messenger.Publish(new MessageHandler(this, HomeConstants.RESULT_WHISTLE_VALIDATION_FAILED).WithPayload(err[0])); } } break; case HomeConstants.NAV_WHISTLE_DISPLAY: Settings.ShowWhistlersListMap = !Settings.ShowWhistlersListMap; _messenger.Publish(new MessageHandler(this, HomeConstants.ACTION_SHOW_WHISTLERS)); break; case LandingConstants.ACTION_REGISTER_DONE: { var err = NewUser.IsValid(phoneService); if (err.Length > 0) { _messenger.Publish(new MessageHandler(this, LandingConstants.RESULT_REGISTER_VALIDATION_FAILED).WithPayload(err[0])); return; } onUserUpdate("PUT"); } break; case LandingConstants.ACTION_REGISTER_CONTINUE: _messenger.Publish(new MessageHandler(this, value)); break; case LandingConstants.ACTION_REGISTER_VALIDATE: { var err = NewUser.IsValid(phoneService); if (err.Length > 0) { _messenger.Publish(new MessageHandler(this, LandingConstants.RESULT_REGISTER_VALIDATION_FAILED).WithPayload(err[0])); } else { _messenger.Publish(new MessageHandler(this, value)); } } break; case HomeConstants.NAV_CLEAR_SELECTED_WHISTLER: SelectedWhistleItem = null; RaisePropertyChanged(() => SelectedWhistleItem); break; default: _messenger.Publish(new MessageHandler(this, value)); break; } }