public override async Task InitializeAsync(object navigationData) { await base.InitializeAsync(navigationData); List <ExpirationDate> expirationDates = new List <ExpirationDate>(); List <Product> products = new List <Product>(); try { expirationDates = await _expirationDateService.GetAsync(0); products = await _productService.GetAsync(); } catch (Exception) { await NavigationService.RemoveBackStackAsync(); await NavigationService.NavigateToAsync <LoginViewModel>(); } var datesToNotification = new List <ExpirationDate>(); foreach (ExpirationDate expD in expirationDates) { if (!expD.Collected) { expD.Product = products.Find(p => p.Id == expD.ProductId); datesToNotification.Add(expD); } } foreach (ExpirationDate expD in datesToNotification) { _notificationService.ScheduleNotification(expD.Product.Name + " " + expD.Product.BareCode, "Kończąca się data przydatności " + expD.EndDate); } }
public override async Task InitializeAsync(object navigationData) { Customize = false; IsBeggining = false; IsEnding = false; OnlyCollected = false; SelectedCategories = false; IsBusy = true; var categories = await _categoryService.GetAsync(); AllCategories = new ObservableCollection <Category>(categories); var products = await _productService.GetAsync(); ReportData = new ObservableCollection <ExpirationDate>(await _expirationDateService.GetAsync(0)); foreach (ExpirationDate expD in _reportData) { var product = products.Find(p => p.Id == expD.ProductId); product.Category = categories.Find(c => c.Id == product.CategoryId); expD.Product = product; } IsBusy = false; }
public async override Task InitializeAsync(object navigationData) { ExpirationDates = new ObservableCollection <ExpirationDate>(); try { var tmpDates = await _expirationDatesService.GetAsync(0); var tmpProducts = await _productService.GetAsync(); foreach (ExpirationDate exd in tmpDates) { exd.Product = tmpProducts.Find(p => p.Id == exd.ProductId); } ExpirationDates = ListToObservableConverter <ExpirationDate> .ToObservable(tmpDates); } catch (Exception) { await DialogService.ShowAlertAsync("Nie powiodło się pobieranie danych", "Błąd", "Ok"); } }
private async Task LoadExpirationDatesAsync() { try { this.ExpirationDates = ListToObservableConverter <ExpirationDate> .ToObservable(await _expirationDateService.GetAsync(Id)); } catch (Exception e) { await DialogService.ShowAlertAsync(e.Message, "Błąd pobierania dat przydatności", "Ok"); } }