Пример #1
0
 public Car(CarsModels model, int maxSpeed = 0)
 {
     CarModel     = model;
     CarYearManuf = DateTime.Today.Year;
     CarMaxSpeed  = maxSpeed;
     CarsCreated++;
 }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CarsModels carsModels = db.Car.Find(id);

            db.Car.Remove(carsModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,IdCar,Brand,Model,YearOfProduction,VIN,Series,Phonenumber,PhotoURL,Description,SellingPrice")] CarsModels carsModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carsModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carsModels));
 }
Пример #4
0
 public Car(CarsModels model, CarsColors color, int year, int mileage = 0, int maxSpeed = 200, string info = "")
 {
     CarModel        = model;
     CarColor        = color;
     CarYearManuf    = year;
     CarMileage      = mileage;
     CarMaxSpeed     = maxSpeed;
     AditionalInform = info;
     CarsCreated++;
 }
Пример #5
0
 public Car(CarsModels model, int maxSpeed = 0)
 {
     this._carModel         = model;
     this._carColor         = 0;
     this._carYearManuf     = DateTime.Today.Year;
     this._carMileage       = 0;
     this._carMaxSpeed      = maxSpeed;
     this._additionalInform = "";
     _сarsCreated++;
 }
Пример #6
0
 public Car()
 {
     this._carModel         = 0;
     this._carColor         = 0;
     this._carYearManuf     = DateTime.Today.Year;
     this._carMileage       = 0;
     this._carMaxSpeed      = 200;
     this._additionalInform = "";
     _сarsCreated++;
 }
Пример #7
0
        // GET: CarsModels/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarsModels carsModels = db.Car.Find(id);

            if (carsModels == null)
            {
                return(HttpNotFound());
            }
            return(View(carsModels));
        }
Пример #8
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarsModels carsModels = db.Car.Find(id);

            if (carsModels == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Phonenumber = carsModels.Phonenumber;
            return(View(carsModels));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "ID,IdCar,Brand,Model,YearOfProduction,VIN,Series,Phonenumber,PhotoURL,Description,SellingPrice")] CarsModels carsModels)
        {
            //string fname = Path.GetFileNameWithoutExtension(carsModels.ImageFile.FileName);
            //string extension = Path.GetExtension(carsModels.ImageFile.FileName);
            //fname = fname + DateTime.Now.ToString("yymmssfff") + extension;
            //carsModels.PhotoURL = fname;

            if (ModelState.IsValid)
            {
                string usrID = User.Identity.GetUserId();
                var    o     = db.Owner.Where(x => x.UserID == usrID).FirstOrDefault();
                carsModels.Phonenumber = o.PhoneNumber;
                db.Car.Add(carsModels);
                o.Cars.Add(carsModels);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(carsModels));
        }