Пример #1
0
        public ActionResult AddColor(AddColorViewModel vm)
        {
            tblColorsService service = new tblColorsService();

            service.addColor(vm.newColor);
            return(RedirectToAction("CarIndex"));
        }
Пример #2
0
        public void VerwijderKleur(int id)
        {
            System.Diagnostics.Debug.WriteLine(id);

            tblColorsService colorService = new tblColorsService();

            colorService.deleteColor(id);
        }
Пример #3
0
        public ActionResult AddColor()
        {
            tblColorsService  service = new tblColorsService();
            AddColorViewModel vm      = new AddColorViewModel();

            vm.colors = service.getColors();
            return(View(vm));
        }
Пример #4
0
        public ActionResult AddCar()
        {
            AddCarViewModel  vm         = new AddCarViewModel();
            tblCarsService   cservice   = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();

            vm.brandChoice = bservice.getBrands();
            vm.colorChoice = colservice.getColors();
            return(View(vm));
        }
Пример #5
0
        public ActionResult AddCar(AddCarViewModel vm)
        {
            tblCarsService   cservice   = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();
            tblCars          car        = new tblCars();

            car.BrandID               = vm.selectedBrandId;
            car.ColorID               = vm.selectedColorId;
            car.CarModel              = vm.car.CarModel;
            car.CarDescription        = vm.car.CarDescription;
            car.CarFuel               = vm.fuelChoice.ToString();
            car.CarKilometers         = vm.car.CarKilometers;
            car.CarPrice              = vm.car.CarPrice;
            car.CarEquipment          = vm.car.CarEquipment;
            car.CarYearOfConstruction = vm.car.CarYearOfConstruction;
            car.Sold              = (byte)0;
            car.C02Emissions      = vm.car.C02Emissions;
            car.PowerKW           = vm.car.PowerKW;
            car.PowerPK           = vm.car.PowerPK;
            car.CylinderCapacity  = vm.car.CylinderCapacity;
            car.FirstRegistration = vm.car.FirstRegistration;
            car.Transmission      = vm.transmissionChoice.ToString();
            car.Createdate        = DateTime.Now.Date;
            cservice.addCar(car);
            List <HttpPostedFileBase> files = vm.files.ToList();

            for (int i = 0; i < files.Count(); i++)
            {
                if (files.ElementAt(i) != null && files.ElementAt(i).ContentLength > 0)
                {
                    tblImages Image = new tblImages();
                    System.Diagnostics.Debug.WriteLine("image");
                    Image.CarID      = car.CarID;
                    Image.ImageOrder = i;
                    Image.ImagePath  = @"Cars\Car" + car.CarID + @"\Image";
                    tblImagesService iservice = new tblImagesService();
                    iservice.AddImage(Image);
                    Image.ImagePath = @"Cars/Car" + car.CarID + @"/Image" + Image.ImageID + ".jpg";
                    iservice.UpdateImage(Image);
                    CSCBelgiumCloudService cloudservice = new CSCBelgiumCloudService();
                    cloudservice.UploadImageAsBlob(Image, files.ElementAt(i));
                }
                else
                {
                    Debug.WriteLine("file null");
                }
            }
            return(RedirectToAction("CarIndex"));
        }
Пример #6
0
        public ActionResult Cars(CarsViewModel vm)
        {
            Debug.WriteLine(vm.minKM);
            Debug.WriteLine(vm.maxKM);
            Debug.WriteLine(vm.minPrice);
            Debug.WriteLine(vm.maxPrice);

            List <tblCars> cars = new List <tblCars>();

            tblCarsService   service    = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();

            cars = service.getAllCars().ToList();
            if (vm.selectedBrandId != 0)
            {
                cars = service.FilterByBrand(cars, bservice.getBrands().ElementAt(vm.selectedBrandId - 2)).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.selectedColorId != 0)
            {
                cars = service.FilterByColor(cars, colservice.getColors().ElementAt(vm.selectedColorId - 1)).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.transmissionChoice == Transmission.Automaat || vm.transmissionChoice == Transmission.Manueel)
            {
                cars = cars.Where(a => a.Transmission == vm.transmissionChoice.ToString()).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.fuelChoice == Fuel.Benzine || vm.fuelChoice == Fuel.Diesel || vm.fuelChoice == Fuel.Elektrisch || vm.fuelChoice == Fuel.Hybride || vm.fuelChoice == Fuel.LPG)
            {
                cars = cars.Where(a => a.CarFuel == vm.fuelChoice.ToString()).ToList();
                Debug.WriteLine(cars.Count());
            }
            cars = service.FilterByKM(cars, vm.minKM, vm.maxKM).ToList();
            Debug.WriteLine(cars.Count());
            cars = service.FilterByPrice(cars, Convert.ToInt32(vm.minPrice), Convert.ToInt32(vm.maxPrice)).ToList();
            Debug.WriteLine(cars.Count());

            vm.cars        = cars;
            vm.minKM       = service.getAllCars().Min(a => a.CarKilometers);
            vm.maxKM       = service.getAllCars().Max(a => a.CarKilometers);
            vm.minPrice    = service.getAllCars().Min(b => b.CarPrice);
            vm.maxPrice    = service.getAllCars().Max(b => b.CarPrice);
            vm.brandChoice = bservice.getBrands();
            vm.colorChoice = colservice.getColors();
            vm.images      = service.getAllImages();
            vm.CarsInStock = service.getAllCars().Where(a => a.Sold == 0).Count();
            return(View(vm));
        }
Пример #7
0
        public ActionResult EditCar(int carID)
        {
            EditCarViewModel vm         = new EditCarViewModel();
            tblCarsService   cservice   = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();

            vm.car                = cservice.getCar(carID);
            vm.selectedBrandId    = vm.car.BrandID;
            vm.selectedColorId    = vm.car.ColorID;
            vm.brandChoice        = bservice.getBrands();
            vm.colorChoice        = colservice.getColors();
            vm.fuelChoice         = (Fuel)Enum.Parse(typeof(Fuel), vm.car.CarFuel, true);
            vm.transmissionChoice = (Transmission)Enum.Parse(typeof(Transmission), vm.car.Transmission, true);

            return(View(vm));
        }
Пример #8
0
        public ActionResult Cars()
        {
            CarsViewModel    vm         = new CarsViewModel();
            tblCarsService   service    = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();

            vm.cars = service.getAllCars();
            if (vm.cars.Count() > 0)
            {
                vm.minKM       = service.getAllCars().Min(a => a.CarKilometers);
                vm.maxKM       = service.getAllCars().Max(a => a.CarKilometers);
                vm.minPrice    = service.getAllCars().Min(b => b.CarPrice);
                vm.maxPrice    = service.getAllCars().Max(b => b.CarPrice);
                vm.brandChoice = bservice.getBrands();
                vm.colorChoice = colservice.getColors();
                vm.images      = service.GetFrontImages();
                vm.CarsInStock = service.getAllCars().Where(a => a.Sold == 0).Count();
            }

            return(View(vm));
        }
Пример #9
0
        public ActionResult EditCar(AddCarViewModel vm)
        {
            tblCarsService   cservice   = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();
            tblImagesService iservice   = new tblImagesService();
            tblCars          car        = cservice.getCar(vm.car.CarID);

            car.BrandID               = vm.selectedBrandId;
            car.ColorID               = vm.selectedColorId;
            car.CarModel              = vm.car.CarModel;
            car.CarDescription        = vm.car.CarDescription;
            car.CarFuel               = vm.fuelChoice.ToString();
            car.CarKilometers         = vm.car.CarKilometers;
            car.CarPrice              = vm.car.CarPrice;
            car.CarEquipment          = vm.car.CarEquipment;
            car.CarYearOfConstruction = vm.car.CarYearOfConstruction;
            car.Sold              = (byte)0;
            car.C02Emissions      = vm.car.C02Emissions;
            car.PowerKW           = vm.car.PowerKW;
            car.PowerPK           = vm.car.PowerPK;
            car.CylinderCapacity  = vm.car.CylinderCapacity;
            car.FirstRegistration = vm.car.FirstRegistration;
            car.Transmission      = vm.transmissionChoice.ToString();
            car.Createdate        = DateTime.Now.Date;
            cservice.editCar(car);
            List <HttpPostedFileBase> files = vm.files.ToList();

            //ICollection<tblImages> images = cservice.GetImagesByCar(car);
            //for (int i = 0; i < images.Count() ; i++)
            //{
            //    tblImages temp = images.ElementAt(i);
            //    temp.Image = ResizeImage(temp.Image, 0.70f);
            //    iservice.UpdateImage(temp);
            //}
            for (int i = 0; i < files.Count(); i++)
            {
                if (files.ElementAt(i) != null && files.ElementAt(i).ContentLength > 0)
                {
                    if (i == 0)
                    {
                        iservice.DeleteAllImagesOfCar(vm.car);
                    }
                    tblImages Image = new tblImages();
                    System.Diagnostics.Debug.WriteLine("image");
                    MemoryStream target = new MemoryStream();
                    files.ElementAt(i).InputStream.CopyTo(target);
                    byte[] image = target.ToArray();
                    Image.CarID      = car.CarID;
                    Image.ImageOrder = i;
                    Image.ImagePath  = "Temp";
                    iservice.AddImage(Image);
                    Image.ImagePath = @"Cars/Car" + car.CarID + @"/Image" + Image.ImageID + ".jpg";
                    iservice.UpdateImage(Image);
                }
                else
                {
                    Debug.WriteLine("file null");
                    return(RedirectToAction("CarIndex"));
                }
            }
            return(RedirectToAction("CarIndex"));
        }