public async void Start(Guid customerId) { try { if (IsRestored) { Customer = UnitOfWork.Entities.WithIdFromCache(customerId); } else { Customer = await UnitOfWork.Entities.WithIdAsync(customerId); } } catch (Exception e) { ErrorHandler.Handle(e); } }
public async void Start() { try { using (Busy.GetTicket()) { Func <IQueryable <Customer>, IOrderedQueryable <Customer> > orderBy = q => q.OrderBy(x => x.CompanyName); if (!string.IsNullOrEmpty(SearchText)) { Search(IsRestored); } else { Customers = new BindableCollection <Customer>( IsRestored ? UnitOfWork.Entities.AllInCache(orderBy) : await UnitOfWork.Entities.AllAsync(orderBy)); } } } catch (Exception e) { ErrorHandler.Handle(e); } }
public async void Search(bool cache) { try { using (Busy.GetTicket()) { if (string.IsNullOrEmpty(SearchText)) { Start(); return; } Expression <Func <Customer, bool> > predicate = x => x.CompanyName.Contains(SearchText); Func <IQueryable <Customer>, IOrderedQueryable <Customer> > orderBy = q => q.OrderBy(x => x.CompanyName); Customers = new BindableCollection <Customer>( cache ? UnitOfWork.Entities.FindInCache(predicate, orderBy) : await UnitOfWork.Entities.FindAsync(predicate, orderBy)); } } catch (Exception e) { ErrorHandler.Handle(e); } }