public async Task <EditVM> Handle(Query request, CancellationToken cancellationToken) { DataContext db = factory.Get(); List <Address> context = await db.Addresses.Include(t => t.Trader.Addresses).ToListAsync(); var tradersDto = new EditVM { Addresses = Mapper.Map <List <AddressVM> >(context) }; return(await Task.FromResult(tradersDto)); }
/// <summary> /// Constructor. It creates a dbContext Factory and initializes the database. /// </summary> public UnitOfWorkFixture() { _contextFactory = new DataContextFactory(); _contextFactory.Get().Database.Initialize(false); IRepositoryProvider provider = new RepositoryProvider(new RepositoryFactories()); provider.DataContextFactory = _contextFactory; _unitOfWork = new UnitOfWork(provider); }
public Task <HomeVM> Handle(Query request, CancellationToken cancellationToken) { DataContext db = factory.Get(); List <Trader> allTraders = db.Traders.Include(t => t.Addresses).ToList(); HomeVM result = new HomeVM { Traders = Mapper.Map <List <TraderVM> >(allTraders) }; return(Task.FromResult(result)); }
/// <summary> /// Constructor. It creates a dbContext Factory and initializes the database. /// </summary> public DataContextFixture() { _contextFactory = new DataContextFactory(); _contextFactory.Get().Database.Initialize(false); }