public async Task <IEnumerable <CarEngineWithGearboxModel> > GetAllEngineGearboxPairsAsync()
        {
            var items = await ReadRepository.GetAllAsync <EngineSupportsGearbox>(_engineGearboxRelationsProvider.JoinGearboxAndEngine);

            var result = items.GroupBy(x => new { x.ModelId, x.EngineId }).Select(x => x.First());

            return(Mapper.Map <IEnumerable <CarEngineWithGearboxModel> >(result));
        }
        public async Task ListAllAsync_ShouldReturnEntities()
        {
            // Arrange
            TestEntity[] entities = _fixture.CreateMany <TestEntity>(2).ToArray();

            var dbContextMock = new DbContextMock <TestDbContext>(_options);

            dbContextMock.CreateDbSetMock(x => x.TestEntities, (x, _) => (x.Id), entities);
            var repository = new ReadRepository <TestEntity, Guid>(() => dbContextMock.Object);

            // Act
            TestEntity[] result = await repository.GetAllAsync();

            // Assert
            result.Should().NotBeNull();
            result.Should().HaveCount(2);
        }
Exemple #3
0
        private async void LoadData()
        {
            try
            {
                _readModels = await _readRepository.GetAllAsync();
                await FilterTextAsync();

                LoadingState = LoadingStates.Loaded;
                var random = new Random();

                SelectedRead = ReadModels?.ElementAt(random.Next(0, ReadModels.Count - 1));
            }
            catch (Exception ex)
            {
                LoadingState = LoadingStates.Error;
            }
        }
        public async Task ListAllAsyncWithSpecification_ShouldApplySpecification()
        {
            // Arrange
            TestEntity[] entities = _fixture.CreateMany <TestEntity>(2).ToArray();

            var dbContextMock = new DbContextMock <TestDbContext>(_options);

            dbContextMock.CreateDbSetMock(x => x.TestEntities, (x, _) => (x.Id), entities);
            var repository = new ReadRepository <TestEntity, Guid>(() => dbContextMock.Object);

            var specification = new Mock <ISpecification <TestEntity> >();

            // Act
            TestEntity[] result = await repository.GetAllAsync(specification.Object);

            // Assert
            result.Should().NotBeNull();
            result.Should().BeOfType(typeof(TestEntity[]));
        }
        public async Task <IEnumerable <BrandModel> > GetAllAsync()
        {
            var brands = await ReadRepository.GetAllAsync <Brand>(_relationsProvider.JoinCountry);

            return(Mapper.Map <IEnumerable <BrandModel> >(brands));
        }
        public async Task <IEnumerable <UserModel> > GetAllAsync()
        {
            var users = await ReadRepository.GetAllAsync <Data.Models.User.User>(_relationsProvider.JoinRole);

            return(Mapper.Map <IEnumerable <UserModel> >(users));
        }
Exemple #7
0
        public async Task <IEnumerable <SupplierModel> > GetAllAsync()
        {
            var suppliers = await ReadRepository.GetAllAsync <Supplier>(_relationsProvider.JoinBrandAndCountry);

            return(Mapper.Map <IEnumerable <SupplierModel> >(suppliers));
        }
        public virtual async Task <IEnumerable <TResponse> > GetAllAsync()
        {
            var items = await ReadRepository.GetAllAsync <TDataModel>();

            return(Mapper.Map <IEnumerable <TResponse> >(items));
        }
        public async Task <IEnumerable <CarEngineModel> > GetAllAsync()
        {
            var items = await ReadRepository.GetAllAsync <CarEngine>(_engineRelationsProvider.JoinEngineType);

            return(Mapper.Map <IEnumerable <CarEngineModel> >(items));
        }