private async void GoBackFromReportRequested(ReportedIssue issue) { if (Device.OS != TargetPlatform.iOS) { await NavigateBackAsync(); } }
async Task ReportButtonTapped() { FillData(); bool isValid = Validate(); if (isValid) { var incident = new ReportedIssue { Type = reportIncidentType, Title = title, Description = description }; if (await FeedbackService.SendIssueAsync(incident)) { await Alert.Toast("Received"); ResetData(); } else { await Alert.Toast("Error on save"); } } else { isValid = false; } }
public CommandHandlerResult Handle(CreateIssueCommand command) { var request = command.Request; var issueToAdd = new ReportedIssue() { BikeId = request.BikeId, Description = request.Description, Solved = false, UtcTime = DateTime.UtcNow, IssueType = request.Type, Title = request.Title }; if (request.StopId.HasValue) { issueToAdd.StopId = request.StopId.Value; FillLatitudeAndLongitude(issueToAdd); } else { issueToAdd.Latitude = request.Latitude.Value; issueToAdd.Longitude = request.Longitude.Value; } issueToAdd.UserId = request.UserId; _db.Issues.Add(issueToAdd); return(CommandHandlerResult.Ok); }
public async Task <IActionResult> NewIssue(ReportedIssue issue) { var email = (await _userManager.GetUserAsync(User)).Email; _emailService.Send("*****@*****.**", $"{issue.Area} - {issue.Type} - {email}", issue.Issue); return(Ok()); }
private static async Task AddLocationToIssue(ReportedIssue issue) { var location = await Device.Location.GetCurrentPosition(); if (location != null) { issue.Latitude = location.Latitude; issue.Longitude = location.Longitude; } }
public async Task SendIssueAsync(ReportedIssue issue) { await AddUserAndBikeIdsToIssue(issue); await AddLocationToIssue(issue); UriBuilder builder = new UriBuilder(GlobalSettings.IssuesEndpoint); builder.Path = "api/Issues"; string uri = builder.ToString(); string result = await _requestProvider.PostAsync <ReportedIssue, string>(uri, issue); }
private async Task AddLocationToIssue(ReportedIssue issue) { ILocationResponse location = await _locationProvider.GetPositionAsync(); if (location is GeoLocation) { var geoLocation = location as GeoLocation; issue.Latitude = geoLocation.Latitude; issue.Longitude = geoLocation.Longitude; } }
public static async Task <bool> SendIssueAsync(ReportedIssue issue) { await AddUserAndBikeIdsToIssue(issue); await AddLocationToIssue(issue); var uri = $"{GlobalSettings.IssuesEndpoint}api/Issues"; if (await BaseApi.Post(uri, issue)) { return(true); } return(false); }
private void FillLatitudeAndLongitude(ReportedIssue issueToAdd) { var stationResponse = _ridesQueries.GetStationAsync(issueToAdd.StopId.Value).Result; if (stationResponse != null) { issueToAdd.Latitude = stationResponse.Latitude; issueToAdd.Longitude = stationResponse.Longitude; } else { issueToAdd.Latitude = 0; issueToAdd.Longitude = 0; } }
private static async Task AddUserAndBikeIdsToIssue(ReportedIssue issue) { if (Settings.UserId == 0) { throw new InvalidOperationException("UserId is not saved"); } if (Settings.CurrentBookingId == 0) { throw new InvalidOperationException("CurrentBookingId is not saved"); } var currentBooking = await RidesService.GetBooking(Settings.CurrentBookingId); issue.BikeId = currentBooking.BikeId; issue.UserId = Settings.UserId; }
public static TModel FromReportedIssue <TModel>(ReportedIssue issue) where TModel : IssueApiModel, new() { var model = new TModel(); model.Id = issue.Id; model.Type = issue.IssueType.ToString(); model.Title = model.Title ?? model.Type.ToString(); model.Solved = issue.Solved; model.Subtitle = issue.Description; model.Station.Latitude = issue.Latitude; model.Station.Longitude = issue.Longitude; model.Station.Id = issue.StopId.HasValue ? issue.StopId.Value : 0; model.Time = issue.UtcTime.ToString("r", CultureInfo.InvariantCulture); return(model); }
private DetailedIssue MapIssue(ReportedIssue issue, RidesResponse ride) { return(new DetailedIssue { IssueId = issue.Id, IssueDate = issue.UtcTime, IssueTitle = issue.Title, IssueDescription = issue.Description, IssueSolved = issue.Solved, IssueType = issue.IssueType.ToString(), UserId = issue.UserId, BikeId = issue.BikeId, BikeSerialNumber = ride?.Bike?.SerialNumber, RideDuration = ride?.Duration ?? 0, RideFrom = ride?.From, RideTo = ride?.To, RideStart = ride?.Start ?? DateTime.UtcNow, RideStop = ride?.Stop ?? DateTime.UtcNow, RideType = ride?.RideType }); }
private async void Report() { IsBusy = true; try { IsValid = true; bool isValid = Validate(); if (isValid) { var incident = new ReportedIssue { Type = _reportIncidentType, Title = Title.Value, Description = Description.Value }; await _feedbackService.SendIssueAsync(incident); MessagingCenter.Send(incident, MessengerKeys.ReportSent); ResetData(); } else { IsValid = false; } } catch (Exception ex) when(ex is WebException || ex is HttpRequestException) { await DialogService.ShowAlertAsync("Communication error", "Error", "Ok"); } catch (Exception ex) { Debug.WriteLine($"Error reporting incident in: {ex}"); } IsBusy = false; }
private void OnReportSent(ReportedIssue issue) { var storyboard = new StoryBoard(); storyboard.Animations.Add(new FadeToAnimation { Opacity = 1, Easing = EasingType.Linear, Duration = "800" }); storyboard.Animations.Add(new TranslateToAnimation { TranslateY = 0, Easing = EasingType.CubicOut, Duration = "800" }); DoneMessageContainer.Animate(storyboard, async() => { await OnDoneMessageAnimationFinished(issue); }); }
private async Task OnDoneMessageAnimationFinished(ReportedIssue issue) { if (Device.RuntimePlatform == Device.iOS) { await Task.Delay(2000); MessagingCenter.Send(issue, MessengerKeys.GoBackFromReportRequest); InitializeDoneMessageContainer(); } else { this.Animate(new FadeToAnimation { Opacity = 0, Easing = EasingType.Linear, Duration = "800", Delay = 2000 }, () => { MessagingCenter.Send(issue, MessengerKeys.GoBackFromReportRequest); }); } }
public UpdateIssueCommand(ReportedIssue issue) { _issue = issue; }
private void OnGoBackFromReportRequested(ReportedIssue issue) { TrySetCurrentPage(typeof(HomePage)); }