private async void SendArmedTrap() { try { progressDialog = ProgressDialog.Show(Activity, Resources.GetString(MyTrap.Droid.Resource.String.loading), Resources.GetString(MyTrap.Droid.Resource.String.arming_trap)); ArmedTrapApiRequest armedTrap = new ArmedTrapApiRequest(); armedTrap.NameKey = selectedTrap.NameKey; armedTrap.Latitude = (float)lastLocation.Latitude; armedTrap.Longitude = (float)lastLocation.Longitude; var response = await TrapApiService.Arm(armedTrap); if (ResponseValidator.Validate(response, Activity)) { ShowAlertArmedTrapSuccessfuly(); } progressDialog.Cancel(); } catch (Exception exception) { InsightsUtils.LogException(exception); } }
public async Task <IHttpActionResult> Arm(ArmedTrapApiRequest request) { request.UserId = (await GetUser()).Id; ArmedTrapRequest armedTrapRequest = Mapper.Map <ArmedTrapRequest>(request); UserResult user = await AppBusiness.Trap.ArmTrap(armedTrapRequest); UserApiResult response = Mapper.Map <UserApiResult>(user); return(Ok(response)); }
public static async Task <UserApiResult> Arm(ArmedTrapApiRequest request) { UserApiResult result = null; try { result = await HttpController.PostData <UserApiResult>(ApiMethods.ArmTrap(), request); if (ResponseValidator.Validate(result)) { UserApiService.SaveUserLogged(result); } } catch (Exception) { result = null; } return(result); }
private async void btnPlaceTrap_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { var dialog = new MessageDialog("You want to place the trap at the current position?"); dialog.Title = "Place Trap"; dialog.Commands.Add(new UICommand { Label = "Yes", Id = 0 }); dialog.Commands.Add(new UICommand { Label = "No", Id = 1 }); var res = await dialog.ShowAsync(); if ((int)res.Id == 0) { ArmedTrapApiRequest armedTrap = new ArmedTrapApiRequest(); armedTrap.NameKey = TRAP_NAMEKEY_SELECTED; armedTrap.Latitude = LAST_LATITUDE; armedTrap.Longitude = LAST_LONGITUDE; var response = await TrapApiService.Arm(armedTrap); if (ResponseValidator.Validate(response)) { var dialogSuccess = new MessageDialog("Trap was placed. You will be notified when someone is gaught!"); dialogSuccess.Title = "Placed Trap!"; dialogSuccess.Commands.Add(new UICommand { Label = "Ok", Id = 0 }); res = await dialogSuccess.ShowAsync(); AppShell.Current.AppFrame.Navigate(typeof(HomePage)); } } }