//private readonly BehaviorSubject<bool> _isBusy_BehaveiorSubject; //public IObservable<bool> IsBusyChanged { get; } //public IQbservable<Supplier> Suppliers => throw new NotImplementedException(); // WRITE public async Task <SupplierDto> CreateAndAddAsync(IDictionary <string, object> data) { //using (var uow = this._billingUowFactoryMethod.Invoke()) Supplier addedSupplier = null; using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false)) { try { addedSupplier = await uow.Suppliers.CreateAndAddAsync(data).ConfigureAwait(false); await uow.CommitAsync().ConfigureAwait(false); } catch (Exception) { Debug.WriteLine("error creating supplier from service"); throw; } } if (addedSupplier == null) { return(null); } var addedSupplierDto = SupplierDto.From(addedSupplier); this._added_Subject.OnNext(addedSupplierDto); return(addedSupplierDto); }
public async Task UpdateAsync(long supplierId, IDictionary <string, object> changes) { Supplier updatedSupplier = null; try { using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false)) { await uow.Suppliers.UpdateAsync(supplierId, changes).ConfigureAwait(false); await uow.CommitAsync().ConfigureAwait(false); updatedSupplier = await uow.Suppliers.GetByIdAsync(supplierId).ConfigureAwait(false); } } catch (Exception ex) { Debug.WriteLine("Error updating supplier from service."); Debug.WriteLine(ex); throw; } var addedSupplierDto = SupplierDto.From(updatedSupplier); this._updated_Subject.OnNext(new[] { addedSupplierDto }); }
public async Task <IReadOnlyCollection <SupplierDto> > GetAllAsync() { IReadOnlyCollection <Supplier> suppliers; //using (var uow = this._billingUowFactoryMethod.Invoke()) using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false)) { suppliers = await uow.Suppliers.GetMultipleAsync().ConfigureAwait(false); } var supplierDTOs = suppliers.Select(s => SupplierDto.From(s)).ToList(); return(supplierDTOs); }