public UserListView() { this.InitializeComponent(); datum = new MonatYearDaten(); uNFI = new Views.Mobile.CostsIncomes.UserNumberFormat(); this.Loaded += UserListView_Loaded; }
/// <summary> /// Rechnet was fur wieviel Category in Cost und Incomen /// dann rechnet ganze Summe von Cost oder Incomen /// </summary> /// <param name="category">Category von CatergoryIncomenCost</param> /// <param name="monat">Monat</param> /// <param name="year">Year</param> /// <returns></returns> public async Task <ObservableCollection <Balance> > HomePageDatenSourceLoadedAsync(CategoryCostIncomen category, int monat, int year) { decimal?summeTemp; ObservableCollection <Balance> data = new ObservableCollection <Balance>(); List <string> listString = new List <string>(); if (category == CategoryCostIncomen.Cost) { List <CategoryNamenCosts> costs = Enum.GetValues(typeof(CategoryNamenCosts)) .Cast <CategoryNamenCosts>() .ToList(); //add alle Category fur nachste rechnung in GetDatenCollection(List<string> listString) foreach (var item in costs) { listString.Add(item.ToString()); } var uNFI = new Views.Mobile.CostsIncomes.UserNumberFormat(); //rechnet ganze Summe von Costs using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeTemp = await dataBase.Costs.AsNoTracking() .Select(c => new { nameCategory = c.CategoryOfCost, price = (decimal?)Decimal.Parse(c.PreisOfCost, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfCost }) .Where(a => a.datum.Month == monat & a.datum.Year == year) .Select(a => a.price).SumAsync(); } _summeItems = (decimal)summeTemp; } else { List <CategoryNamenIncomen> incomen = Enum.GetValues(typeof(CategoryNamenIncomen)) .Cast <CategoryNamenIncomen>() .ToList(); foreach (var item in incomen) { listString.Add(item.ToString()); } var uNFI = new Views.Mobile.CostsIncomes.UserNumberFormat(); //rechnet ganze Summe von Incomen using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeTemp = await dataBase.Incomes.AsNoTracking() .Select(c => new { nameCategory = c.CategoryOfIncome, price = (decimal?)Decimal.Parse(c.PreisOfIncome, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfIncome }) .Where(a => a.datum.Month == monat & a.datum.Year == year) .Select(a => a.price).SumAsync(); } _summeItems = (decimal)summeTemp; } data = await GetDatenCollection(listString); return(data); }