private void CallExecute() { PhoneCallManager.ShowPhoneCallUI(Post.PhoneNumber, "@" + Post.User); _insightsService.TrackEvent("ContactCall", new Dictionary <string, string> { { "PostId", Post.Id } }); }
private async void EditExecute() { if (!_findierService.IsAuthenticated) { NavigationService.Navigate(typeof(AuthenticationPage), true); return; } var type = PostType.Freebie; decimal price = 0; if (IsFixed) { type = PostType.Fixed; // convert the price into a decimal if (!decimal.TryParse(Price, out price) || price < 1) { CurtainPrompt.ShowError("Please enter a valid price."); return; } } else if (IsMoney) { type = PostType.Money; } if (!string.IsNullOrWhiteSpace(Email) && !Email.IsEmail()) { CurtainPrompt.ShowError("Please enter a valid email."); return; } if (!string.IsNullOrWhiteSpace(PhoneNumber) && !PhoneNumber.IsPhoneNumber()) { CurtainPrompt.ShowError("Please enter a valid phone number."); return; } if (string.IsNullOrWhiteSpace(Email) && string.IsNullOrWhiteSpace(PhoneNumber)) { CurtainPrompt.ShowError("Please enter at least one contact method."); return; } var editPostRequest = new EditPostRequest(_post.Id, _post.Text == Text ? null : Text, _post.Type == type ? null : (PostType?)type, _post.Price == price ? null : (decimal?)price, _post.IsNsfw == IsNsfw || !CanEditNsfw ? null : (bool?)IsNsfw, _post.Email == Email ? null : Email, _post.PhoneNumber == PhoneNumber ? null : PhoneNumber); IsLoading = true; var restResponse = await _findierService.SendAsync(editPostRequest); IsLoading = false; if (restResponse.IsSuccessStatusCode) { CurtainPrompt.Show("Edit was saved."); NavigationService.GoBack(); } else { CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error ?? "Problem editing post. Try again later."); } var props = new Dictionary <string, string>(); if (restResponse.IsSuccessStatusCode) { props.Add("Error", restResponse.DeserializedResponse?.Error ?? "Unknown"); props.Add("StatusCode", restResponse.StatusCode.ToString()); } _insightsService.TrackEvent("EditPost", props); }
private async void PublishExecute() { if (!_findierService.IsAuthenticated) { NavigationService.Navigate(typeof(AuthenticationPage), true); return; } var type = PostType.Freebie; decimal price = 0; if (IsFixed) { type = PostType.Fixed; // convert the price into a decimal if (!decimal.TryParse(Price, out price) || price < 1) { CurtainPrompt.ShowError("Please enter a valid price."); return; } } else if (IsMoney) { type = PostType.Money; } if (string.IsNullOrWhiteSpace(Title)) { CurtainPrompt.ShowError("Don't forget to set a title!"); return; } if (Title.Length < 5) { CurtainPrompt.ShowError("The title is a bit too short."); return; } if (!string.IsNullOrWhiteSpace(Email) && !Email.IsEmail()) { CurtainPrompt.ShowError("Please enter a valid email."); return; } if (!string.IsNullOrWhiteSpace(PhoneNumber) && !PhoneNumber.IsPhoneNumber()) { CurtainPrompt.ShowError("Please enter a valid phone number."); return; } if (string.IsNullOrWhiteSpace(Email) && string.IsNullOrWhiteSpace(PhoneNumber)) { CurtainPrompt.ShowError("Please enter at least one contact method."); return; } var createPostRequest = new CreatePostRequest(_category.Id, Title, Text, type, price, IsNsfw, Email, PhoneNumber); IsLoading = true; var restResponse = await _findierService.SendAsync <CreatePostRequest, string>(createPostRequest); IsLoading = false; if (restResponse.IsSuccessStatusCode) { CurtainPrompt.Show("You post is live!"); NavigationService.GoBack(); } else { CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error ?? "Problem publishing post. Try again later."); } var props = new Dictionary <string, string>(); if (restResponse.IsSuccessStatusCode) { props.Add("Error", restResponse.DeserializedResponse?.Error ?? "Unknown"); props.Add("StatusCode", restResponse.StatusCode.ToString()); } _insightsService.TrackEvent("PublishPost", props); }