private void BindCatalog( CatalogKind kind, IFactory <CatalogKind, CatalogModel> catalogModelFactory ) { CatalogModel = catalogModelFactory.Create(kind); }
public Task <Catalog> Create(CatalogKind catalogKind) { var catalog = new Catalog { Kind = catalogKind }; return(Create(catalog)); }
public Catalog(Producer producer, CatalogKind kind, Guid id, string name) { Id = id; Name = name; Kind = kind; Producer = producer; ProducerId = producer.Id; Products = new List <CatalogProduct>(); }
private IDisposable BindCatalog(ICatalogProvider catalogProvider, CatalogKind kind) { Entries = new ObservableCollectionExtended <EntryModel>(); return(catalogProvider.Chats.Connect() .Filter(_filterController) .Sort(_sortingController) .SubscribeOn(TaskPoolScheduler.Default) .ObserveOn(RxApp.MainThreadScheduler) .Bind(Entries) .Subscribe()); }
public MessengerModel( CatalogKind kind, IFactory <CatalogKind, CatalogModel> catalogModelFactory, IFactory <Target, InformerModel> informerModelFactory, IFactory <Target, ExplorerModel> explorerModelFactory, IFactory <Target, EditorModel> editorModelFactory ) { BindCatalog(kind, catalogModelFactory); BindInformer(informerModelFactory).DisposeWith(_modelDisposable); BindExplorer(explorerModelFactory).DisposeWith(_modelDisposable); BindEditor(editorModelFactory).DisposeWith(_modelDisposable); }
public async Task <ICollection <CatalogItem> > GetByKind(CatalogKind catalogKind, CatalogItemKind itemKind) { var catalog = await CatalogService.GetByKind(catalogKind); if (catalog == null) { throw new EntityNotFoundException( $"can't find catalogItem with catalogKind:{catalogKind}", nameof(catalogKind)); } return(await Repository.GetByKind(catalog.Id, itemKind)); }
public async Task <List <CatalogItemAM> > GetCatalogItems(CatalogKind catalogKind, CatalogItemKind catalogItemKind) { var domainItems = await DomainCatalogItemService.GetByKind(catalogKind, catalogItemKind); var result = new List <CatalogItemAM>(); foreach (var domainItem in domainItems) { result.Add(FromDomainEntity(domainItem)); } return(result); }
public CatalogModel( IFactory <ICatalogProvider> catalogProviderFactory, CatalogKind kind) { _filterController = new Subject <Func <EntryModel, bool> >(); _sortingController = new Subject <IComparer <EntryModel> >(); var catalogProvider = catalogProviderFactory.Create(); BindCatalog(catalogProvider, kind).DisposeWith(_modelDisposable); BindSearch(kind).DisposeWith(_modelDisposable); }
private Func <EntryModel, bool> GetFilter(CatalogKind kind) { switch (kind) { case CatalogKind.Bots: return(CatalogFilter.BotFilter); case CatalogKind.Channels: return(CatalogFilter.ChannelFilter); case CatalogKind.Groups: return(CatalogFilter.GroupFilter); case CatalogKind.Direct: return(CatalogFilter.DirectFilter); case CatalogKind.Home: default: return(CatalogFilter.All); } }
public async Task <PricelistAM> CreatePricelistBlank( CatalogKind catalogKind = CatalogKind.Cargo, CatalogItemKind catalogItemKind = CatalogItemKind.Weight) { var catalogItems = await CatalogService.GetCatalogItems(catalogKind, catalogItemKind); var result = new PricelistAM(); foreach (var catalogItem in catalogItems) { var price = new PriceAM { CatalogItemId = catalogItem.Id, CommissionPercentage = Price.DefaultComissionPercentage, Name = catalogItem.Name }; result.Items.Add(price); } return(result); }
private IDisposable BindSearch(CatalogKind kind) { return(this.WhenAnyValue(ctx => ctx.SearchText) .Throttle(TimeSpan.FromMilliseconds(500)) .Subscribe(text => { var sorting = GetSorting(e => e.Order); var filter = GetFilter(kind); if (!string.IsNullOrWhiteSpace(text)) { sorting = GetSorting(e => e.Title); filter = entry => entry.Title.Contains(text) && GetFilter(kind)(entry); } _sortingController.OnNext(sorting); _filterController.OnNext(filter); })); }
public Task <Catalog> GetEntityByKind(CatalogKind kind) { return(Entities.SingleOrDefaultAsync(l => l.Kind.Equals(kind))); }
public async Task <bool> IsExist(CatalogKind kind) { return(await GetByKind(kind) != null); }
public Task <Catalog> GetByKind(CatalogKind kind) { return(Repository.GetEntityByKind(kind)); }