예제 #1
0
        public CarModelQuery(CarModelRepository modelRepository)
        {
            Field <ListGraphType <CarModelType> >("models",
                                                  resolve: context =>
            {
                return(modelRepository.FindAllByPredicate(x => x.Versions));
            });

            Field <CarModelType>("model",
                                 arguments: new QueryArguments(new List <QueryArgument>
            {
                new QueryArgument <IdGraphType>
                {
                    Name = "id"
                }
            }),
                                 resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                if (id <= 0)
                {
                    context.Errors.Add(new ExecutionError("Model Id is invalid or missing"));
                    return(null);
                }

                return(modelRepository.FindBy(x => x.Id == id, x => x.Versions));
            });
        }
예제 #2
0
 public HomeController()
 {
     auditRepository          = new AuditRepository();
     carManufactureRepository = new CarManufactureRepository();
     carModelRepository       = new CarModelRepository();
     carDetailRepository      = new CarDetailRepository();
 }
예제 #3
0
 public CarModelYearDetailController()
 {
     repository          = new CarModelYearDetailRepository();
     carModelRepository  = new CarModelRepository();
     carYearRepository   = new CarYearRepository();
     carDetailRepository = new CarDetailRepository();
 }
예제 #4
0
 public UnitOfWork(AppDbContext context)
 {
     _context           = context;
     CarRepository      = new CarRepository(_context);
     CompanyRepository  = new CompanyRepository(_context);
     CarModelRepository = new CarModelRepository(_context);
 }
예제 #5
0
        public void CanRemoveCarModel()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(9, repo.GetAll().Count);
            repo.Remove(1);
            Assert.AreEqual(8, repo.GetAll().Count);
        }
예제 #6
0
        public void CanRemoveDeal()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(3, repo.GetSpecialOffers().Count);
            repo.RemoveDeal(repo.GetSpecialOffers().FirstOrDefault().SpecialId);
            Assert.AreEqual(2, repo.GetSpecialOffers().Count);
        }
예제 #7
0
        public CarModelMutation(CarModelRepository modelRepository)
        {
            /**
             * NEW MODEL
             */
            Field <CarModelType, CarModel>()
            .Name("createModel")
            .Argument <NonNullGraphType <CarModelInputType> >("model", "model input")
            .ResolveAsync(async ctx =>
            {
                var model = ctx.GetArgument <CarModel>("model");
                return(await modelRepository.Add(model));
            });

            /**
             * UPDATE MODEL
             */
            Field <CarModelType, CarModel>()
            .Name("updateModel")
            .Argument <NonNullGraphType <CarBrandInputType> >("model", "model input")
            .ResolveAsync(async ctx =>
            {
                var model = ctx.GetArgument <CarModel>("model");

                // Check if model exists
                var currentModel = await modelRepository.FindById(model.Id);
                if (currentModel == null)
                {
                    ctx.Errors.Add(new ExecutionError("Model not found"));
                    return(null);
                }
                // Update model
                return(await modelRepository.Update(model));
            });

            /**
             * DELETE MODEL
             */
            Field <CarModelType, CarModel>()
            .Name("deleteModel")
            .Argument <NonNullGraphType <IdGraphType> >("id", "model id input")
            .ResolveAsync(async ctx =>
            {
                var id = ctx.GetArgument <int>("id");

                // Check if model exists
                var currentModel = await modelRepository.FindById(id);
                if (currentModel == null)
                {
                    ctx.Errors.Add(new ExecutionError("Model not found"));
                    return(null);
                }
                // delete model
                await modelRepository.Remove(id);

                return(null);
            });
        }
예제 #8
0
        public UnitOfWork(AllianzDBContext context)
        {
            _context = context;

            BodyTypes   = new BodyTypeRepository(_context);
            CarMake     = new CarMakeRepository(_context);
            CarModel    = new CarModelRepository(_context);
            VehicleInfo = new VehicleInfoRepository(_context);
            Customer    = new CustomerRepository(_context);
        }
        public void GetCarModelNameById_ShouldReturnCorrectValue()
        {
            //Arrange
            var sut = new CarModelRepository(_mockContext.Object);
            var id  = 3;
            //Act
            var returnedValue = sut.GetCarModelNameById(id);

            //Assert
            Assert.Equal(GetMockCarModels().Where(x => x.Id == id).FirstOrDefault().ModelName, returnedValue);
        }
        public void ManageCarModel_CarObj_IsNull()
        {
            //Arrange
            var sut = new CarModelRepository(_mockContext.Object);

            //Act
            var returnedValue = sut.ManageCarModel(null);

            //Assert
            Assert.Equal(0, returnedValue);
        }
예제 #11
0
        public void CanAddCarModel()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(9, repo.GetAll().Count);
            repo.Add(new CarModel()
            {
                MakeId = 1, CarModelName = "Big"
            });
            Assert.AreEqual(10, repo.GetAll().Count);
        }
예제 #12
0
 public AuditController()
 {
     carManufactureRepository     = new CarManufactureRepository();
     cityRepository               = new CityRepository();
     carModelRepository           = new CarModelRepository();
     carYearRepository            = new CarYearRepository();
     carDetailRepository          = new CarDetailRepository();
     carModelYearDetailRepository = new CarModelYearDetailRepository();
     auditRepository              = new AuditRepository();
     auditTempRepository          = new AuditTempRepository();
 }
예제 #13
0
        public void CanAddDeal()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(3, repo.GetSpecialOffers().Count);
            repo.AddDeal(new Special()
            {
                SpecialMessage = "gogog"
            });
            Assert.AreEqual(4, repo.GetSpecialOffers().Count);
        }
예제 #14
0
 protected void OnComboMarkChanged(object sender, EventArgs e)
 {
     if (comboMark.SelectedItem == null)
     {
         comboModel.ItemsList = null;
         Entity.CarModel      = null;
         return;
     }
     comboModel.ItemsList = CarModelRepository.GetCarModels(UoW, comboMark.SelectedItem as CarBrand);
     if (Entity.CarModel != null)
     {
         comboModel.SelectedItem = Entity.CarModel;
     }
 }
        public void ManageCarModel_CarObj_IsNotNull_Edit_ShouldCallCorrectMethods()
        {
            //Arrange
            var sut = new CarModelRepository(_mockContext.Object);

            //Act
            _ = sut.ManageCarModel(new CarModel()
            {
                ModelName = "m2"
            });

            //Assert
            _mockContext.Verify(x => x.CarModels.Add(It.IsAny <CarModel>()), Times.Never);
            _mockContext.Verify(x => x.SaveChanges(), Times.Once);
        }
예제 #16
0
        public BaseUnitOfWork(ExtraInfo extra = null)
        {
            _context = new ClassicsContext(extra);

            ProfileRepository   = new ProfileRepository(_context);
            UserRepository      = new UserRepository(_context);
            AddressRepository   = new AddressRepository(_context);
            BlobFileRepository  = new BlobFileRepository(_context);
            BrandRepository     = new BrandRepository(_context);
            CarModelRepository  = new CarModelRepository(_context);
            MyCarRepository     = new MyCarRepository(_context);
            ProductRepository   = new ProductRepository(_context);
            SerieRepository     = new SerieRepository(_context);
            SupplierRepository  = new SupplierRepository(_context);
            AlertRepository     = new AlertRepository(_context);
            UserAlertRepository = new UserAlertRepository(_context);
        }
예제 #17
0
        private void FillCarModel()
        {
            var repository = new CarModelRepository();

            repository.AddIfNotExist(new CarModel()
            {
                Name = "Opel"
            });
            repository.AddIfNotExist(new CarModel()
            {
                Name = "Nissan"
            });
            repository.AddIfNotExist(new CarModel()
            {
                Name = "Ford"
            });
            repository.AddIfNotExist(new CarModel()
            {
                Name = "KIA"
            });
        }
        public void GetAllModelsByMake_ShouldReturnCorrectValue()
        {
            //Arrange
            var sut = new CarModelRepository(_mockContext.Object);

            var expectedCarModels = new List <CarModel>()
            {
                new CarModel()
                {
                    Id = 2, ModelName = "m2"
                }, new CarModel()
                {
                    Id = 4, ModelName = "m4"
                }
            };

            //Act
            var returnedValue = sut.GetAllModelsByMake(2);

            //Assert
            Assert.IsType <List <CarModel> >(returnedValue);
            Assert.Equal(expectedCarModels.Count, returnedValue.Count);
            Assert.Equal(expectedCarModels, returnedValue, new CarModelComparator());
        }
예제 #19
0
 public CarModelController()
 {
     repository            = new CarModelRepository();
     manufactureRepository = new CarManufactureRepository();
 }
예제 #20
0
        public void CanGetCarModel()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual("Liberty", repo.Get(1).CarModelName);
        }
예제 #21
0
        public void CanGetAllCarModel()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(9, repo.GetAll().Count);
        }
예제 #22
0
 public Controller()
 {
     _repository = new CarModelRepository();
 }
예제 #23
0
        public void CanGetAllDeal()
        {
            var repo = new CarModelRepository();

            Assert.AreEqual(3, repo.GetSpecialOffers().Count);
        }
예제 #24
0
 public CarDetailController()
 {
     carModelRepository = new CarModelRepository();
     repository         = new CarDetailRepository();
 }