private async void InitCurrentTrip(bool isLoggedIn) { var currentTripCategory = TripCategories.FirstOrDefault(t => t.Type == CategoryType.CurrentTrip); var currentTrip = !isLoggedIn || currentTripCategory == null || currentTripCategory.Items.Count == 0 ? null : currentTripCategory.Items[0]; WeatherForecast weather = null; if (currentTrip != null) { var flightInfo = currentTrip.DepartureFlight.FlightInfo; var locationId = flightInfo.Flight.Destination.LocationId; var departure = flightInfo.Departure ?? DateTime.Now; weather = await _data.GetWeatherForecastByIdAsync(locationId, departure); ApplicationData.Current.LocalSettings.Values["locationId"] = locationId; ApplicationData.Current.LocalSettings.Values["locationName"] = flightInfo.Flight.Source.City; ApplicationData.Current.LocalSettings.Values["departure"] = String.Format("{0:dd/MM/yyyy}", departure); } CurrentTrip = currentTrip; Weather = weather; IsGlanceVisible = currentTrip != null; }
private void InitializeCurrentTrip(bool isLoggedIn) { var currentTripCategory = TripCategories.FirstOrDefault(t => t.Type == CategoryType.CurrentTrip); var currentTrip = !isLoggedIn || currentTripCategory == null || currentTripCategory.Items.Count == 0 ? null : currentTripCategory.Items[0]; CurrentTrip = currentTrip; IsGlanceVisible = currentTrip != null; }
private async void DeleteCategory() { DeleteCategoryDialog dialog = new DeleteCategoryDialog(new ObservableCollection <Category>(TripCategories)); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { if (dialog.SelectedCategory != null) { _tripRepository.DeleteCategoryWithItems(dialog.SelectedCategory.Id); TripCategories.Remove(dialog.SelectedCategory); DeleteItemsWithCategory(dialog.SelectedCategory); BuildItemList(); } } }
private async void AddCategory() { AddCategoryDialog dialog = new AddCategoryDialog(); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { if (!String.IsNullOrEmpty(dialog.CategoryName)) { if (!TripCategories.Any(c => c.Name == dialog.CategoryName)) { Category catToAdd = new Category(dialog.CategoryName); int catId = await _tripRepository.AddTripCategory(Trip.Id, catToAdd); catToAdd.Id = catId; TripCategories.Add(catToAdd); BuildItemList(); } } } }
public async void AddGeneralItem() { AddGeneralItemDialog dialog = new AddGeneralItemDialog(); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { if (dialog.SelectedItem != null && dialog.SelectedCategory != null) { if (!TripCategories.Any(c => c.Id == dialog.SelectedCategory.Id)) { int id = await _tripRepository.AddTripCategory(Trip.Id, new Category(dialog.SelectedCategory.Name)); dialog.SelectedCategory.Id = id; } await AddItem(dialog.SelectedItem.Name, dialog.SelectedCategory, dialog.Amount); BuildItemList(); } } }