Esempio n. 1
0
 public ICollection <tblImages> GetImagesByCar(tblCars car)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         return(db.tblImages.Where(a => a.CarID == car.CarID).ToList());
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("carId,catId,Car,color,Model_No,Brand_Name,purchase_date")] tblCars tblCars)
        {
            if (id != tblCars.carId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(tblCars);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tblCarsExists(tblCars.carId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["catId"] = new SelectList(db.tblCategories, "catId", "Description", tblCars.catId);
            return(View(tblCars));
        }
Esempio n. 3
0
 public void editCar(tblCars car)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public void addCar(tblCars car)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         db.tblCars.Add(car);
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public void DeleteAllImagesOfCar(tblCars car)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         db.tblImages.RemoveRange(db.tblImages.Where(a => a.CarID == car.CarID));
         db.SaveChanges();
     }
 }
Esempio n. 6
0
 public void deleteCar(int CarID)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         tblImagesDAO imagesdao = new tblImagesDAO();
         imagesdao.DeleteAllImagesOfCar(getCar(CarID));
         tblCars car = getCar(CarID);
         db.Entry(car).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
        public async Task <IActionResult> Create([Bind("carId,catId,Car,color,Model_No,Brand_Name,purchase_date")] tblCars tblCars)
        {
            if (ModelState.IsValid)
            {
                db.Add(tblCars);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["catId"] = new SelectList(db.tblCategories, "catId", "Description", tblCars.catId);
            return(View(tblCars));
        }
Esempio n. 8
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"));
        }
Esempio n. 9
0
 public bool isSold(tblCars car)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         if (car.Sold == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 10
0
 public void SellCar(tblCars car, bool sold)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         if (sold)
         {
             car.Sold            = (byte)1;
             db.Entry(car).State = EntityState.Modified;
             db.SaveChanges();
         }
         else
         {
             car.Sold            = (byte)0;
             db.Entry(car).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
 }
Esempio n. 11
0
        public IActionResult Reservation_Create(ReservationNew Vm)
        {
            var cars = new tblCars
            {
                catId      = Vm.category.catId,
                Car        = Vm.car.Car,
                color      = Vm.car.Color,
                Model_No   = Vm.car.Model,
                Brand_Name = Vm.car.Brand
            };
            var cus = new tblCustomer
            {
                First_Name = Vm.customer.FirstName,
                Last_Name  = Vm.customer.LastName,
                Email      = Vm.customer.EmailAddress,
                CNIC       = Vm.customer.CNIC,
                mobileno   = Vm.customer.MobileNo,
                state      = Vm.customer.State,
            };

            var loc = new tbllocation
            {
                fLocation     = Vm.location.fromLocation,
                tLocation     = Vm.location.toLocation,
                fDate         = Vm.location.fromDate,
                tDate         = Vm.location.toDate,
                state         = Vm.location.Stateloc,
                country       = Vm.location.Countryloc,
                streetNo      = Vm.location.StreetNo,
                streetAddress = Vm.location.Address,
                city          = Vm.location.City
            };


            db.tblCars.Add(cars);
            db.tblCustomer.Add(cus);
            db.tbllocation.Add(loc);

            db.SaveChanges();

            return(View());
        }
Esempio n. 12
0
 public void DeleteAllImagesOfCar(tblCars car)
 {
     dao.DeleteAllImagesOfCar(car);
 }
Esempio n. 13
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"));
        }
Esempio n. 14
0
 public ICollection <tblImages> GetImagesByCar(tblCars car)
 {
     return(dao.GetImagesByCar(car));
 }
Esempio n. 15
0
 public void editCar(tblCars car)
 {
     dao.editCar(car);
 }
Esempio n. 16
0
 public void addCar(tblCars car)
 {
     dao.addCar(car);
 }
Esempio n. 17
0
 public bool isSold(tblCars car)
 {
     return(dao.isSold(car));
 }
Esempio n. 18
0
 public void SellCar(tblCars car, bool sold)
 {
     dao.SellCar(car, sold);
 }