示例#1
0
        public ActionResult addSliderImage(AddSliderImageViewModel vm)
        {
            tblSlidesService service = new tblSlidesService();
            tblSlides        slide   = new tblSlides();

            if (vm.newSlide.CaptionText == null)
            {
                vm.newSlide.CaptionText = " ";
            }
            if (ModelState.IsValid)
            {
                Debug.WriteLine("test:" + vm.newSlide.CationColor);
                slide.CaptionText      = vm.newSlide.CaptionText;
                slide.CaptionAlignment = vm.alignment.ToString();
                slide.CationColor      = vm.newSlide.CationColor;
                if (service.getSlides().Count() != 0)
                {
                    slide.SlideOrder = service.getSlides().Select(a => a.SlideOrder).Max() + 1;
                }
                else
                {
                    slide.SlideOrder = 1;
                }



                HttpPostedFileBase file = Request.Files["txtAfbeelding"];

                if (file != null && file.ContentLength > 0)
                {
                    System.Diagnostics.Debug.WriteLine("image");
                    MemoryStream target = new MemoryStream();
                    file.InputStream.CopyTo(target);
                    byte[] image = target.ToArray();
                    slide.ImagePath = @"Slides/Slide";
                    service.addSlide(slide);
                    slide.ImagePath = @"Slides/Slide" + slide.SlideID + @"/slide.jpg";
                    service.UpdateSlide(slide);
                    CSCBelgiumCloudService cloudservice = new CSCBelgiumCloudService();
                    cloudservice.UploadImageAsBlob(slide, file);
                    return(RedirectToAction("ManageSliderImages"));
                }
                else
                {
                    Debug.WriteLine("file null");
                    return(View());
                }
            }
            else
            {
                Debug.WriteLine("modelstate invalid");
                return(View());
            }
        }
示例#2
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"));
        }
示例#3
0
        public ActionResult AddRim(AddRimViewModel vm)
        {
            tblRimsService      service  = new tblRimsService();
            tblRimBrandsService bservice = new tblRimBrandsService();
            tblRims             rim      = new tblRims();

            rim.RimBrandID = vm.selectedBrandId;
            rim.RimModel   = vm.rim.RimModel;
            rim.RimPrice   = vm.rim.RimPrice;
            rim.Sold       = (byte)0;
            service.addRim(rim);
            List <HttpPostedFileBase> files = vm.files.ToList();

            for (int i = 0; i < files.Count(); i++)
            {
                if (files.ElementAt(i) != null && files.ElementAt(i).ContentLength > 0)
                {
                    tblRimImages Image = new tblRimImages();
                    System.Diagnostics.Debug.WriteLine("image");
                    MemoryStream target = new MemoryStream();
                    files.ElementAt(i).InputStream.CopyTo(target);
                    byte[] image = target.ToArray();
                    Image.RimID     = rim.RimID;
                    Image.ImagePath = @"Rims/Rim" + rim.RimID + @"/Image";
                    tblRimsService rimservice = new tblRimsService();
                    rimservice.addRimImage(Image);
                    Image.ImagePath = @"Rims/Rim" + rim.RimID + @"/Image" + Image.ImageID + ".jpg";
                    rimservice.UpdateImage(Image);
                    CSCBelgiumCloudService cloudservice = new CSCBelgiumCloudService();
                    cloudservice.UploadImageAsBlob(Image, files.ElementAt(i));
                }
                else
                {
                    Debug.WriteLine("file null");
                }
            }
            return(RedirectToAction("ManageRims"));
        }