async Task ExecuteLoadItemsCommand() { IsBusy = true; int HeightList = 0; double Cost = 0; double Income = 0; try { RegistersList.Clear(); var idUser = Application.Current.Properties["userId"].ToString(); usersServices = new UsersServices(); var userInfo = await usersServices.GetUserInfo(idUser); UserInfo = userInfo.data; registersServices = new RegistersServices(); var registersList = await registersServices.GetAllRegisters(idUser); foreach (ItemRegister itemRegister in registersList.data.items) { HeightList = (itemRegister.data.Count * 40) + (10 * itemRegister.data.Count) + 30; foreach (ItemDetail itemDetail in itemRegister.data) { if (itemDetail.type == "chiphi") { Cost += itemDetail.money; } if (itemDetail.type == "thunhap") { Income += itemDetail.money; } } itemRegister.AddProperty(HeightList, Cost, Income); RegistersList.Add(itemRegister); HeightList = 0; Cost = 0; Income = 0; } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task InitializeDataAsync() { var typeConst = new TypeMethod(); var registersServices = new RegistersServices(); var usersServices = new UsersServices(); int HeightList = 0; double Cost = 0; double Income = 0; var idUser = Application.Current.Properties["userId"].ToString(); User = await usersServices.GetUserAsync(idUser); RegistersList = await registersServices.GetAllRegisters(idUser); foreach (ItemRegister itemRegister in RegistersList.data.items) { HeightList = (itemRegister.data.Count * 40) + (10 * itemRegister.data.Count) + 30; //Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(itemList)); foreach (ItemDetail itemDetail in itemRegister.data) { if (itemDetail.type == typeConst.Cost) { Cost += itemDetail.money; } if (itemDetail.type == typeConst.Income) { Income += itemDetail.money; } } itemRegister.AddProperty(HeightList, Cost, Income); HeightList = 0; Cost = 0; Income = 0; } }