internal void InitialAssignValueAsync(int currentPage) { try { CurrentPage = currentPage; var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); var model = RealmDb.All <InventoryResponseModel>().ToList(); if (model.Count > 0) { StockInventoryCollection = model.Where(x => x.Status != "Empty").ToList(); EmptyInventoryCollection = model.Where(x => x.Status == "Empty").ToList(); StockTotals = StockInventoryCollection.Sum(x => x.Quantity); EmptyTotals = EmptyInventoryCollection.Sum(x => x.Quantity); } else { InventoryCommandRecieverAsync(); } } catch (Exception ex) { Crashes.TrackError(ex); } }
public async void InventoryCommandRecieverAsync() { InventoryDetailModel model = null; try { Loader.StartLoading(); model = await _dashboardService.GetInventoryAsync(AppSettings.SessionId); var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); RealmDb.Write(() => { foreach (var item in model.InventoryResponseModel) { RealmDb.Add(item); } }); StockInventoryCollection = model.InventoryResponseModel.Where(x => x.Status != "Empty").ToList(); EmptyInventoryCollection = model.InventoryResponseModel.Where(x => x.Status == "Empty").ToList(); StockTotals = StockInventoryCollection.Sum(x => x.Quantity); EmptyTotals = EmptyInventoryCollection.Sum(x => x.Quantity); } catch (Exception ex) { Crashes.TrackError(ex); } finally { model = null; Loader.StopLoading(); } }