Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            RepairsModels repairsModels = db.RepairsModels.Find(id);

            db.RepairsModels.Remove(repairsModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ID,IdCar,Name,Description,RepairPrice")] RepairsModels repairsModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(repairsModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(repairsModels));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,IdCar,Name,Description,RepairPrice")] RepairsModels repairsModels)
        {
            if (ModelState.IsValid)
            {
                string usrID = User.Identity.GetUserId();
                var    o     = db.Owner.Where(x => x.UserID == usrID).FirstOrDefault();
                o.Repairs.Add(repairsModels);
                db.RepairsModels.Add(repairsModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(repairsModels));
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairsModels repairsModels = db.RepairsModels.Find(id);

            if (repairsModels == null)
            {
                return(HttpNotFound());
            }
            return(View(repairsModels));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,CarId,Name,Description,RepairPrice")] RepairsModels repairsModels)
        {
            if (ModelState.IsValid)
            {
                db.Repair.Add(repairsModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            string UserEmail = User.Identity.GetUserName();

            OwnerModels      owner = db.Owner.Single(a => a.Email == UserEmail);
            List <CarModels> Car   = db.Car.Where(a => a.OwnerID == owner.ID).ToList();

            ViewBag.CarId = new SelectList(Car, "ID", "Make", repairsModels.CarId);
            return(View(repairsModels));
        }
Ejemplo n.º 6
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairsModels repairsModels = db.RepairsModels.Find(id);

            if (repairsModels == null)
            {
                return(HttpNotFound());
            }
            List <CarsModels> carList = db.Car.ToList();

            ViewBag.Cars = new SelectList(carList, "ID", "VIN");
            return(View(repairsModels));
        }
Ejemplo n.º 7
0
        // GET: RepairsModels/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairsModels repairsModels = db.RepairsModels.Find(id);
            var           CarInfo       = db.Car.FirstOrDefault(x => x.ID == repairsModels.IdCar);

            ViewBag.CarModel  = CarInfo.Model;
            ViewBag.CarVIN    = CarInfo.VIN;
            ViewBag.CarSeries = CarInfo.Series;
            ViewBag.CarBrand  = CarInfo.Brand;
            ViewBag.PhotoURL  = CarInfo.PhotoURL;

            if (repairsModels == null)
            {
                return(HttpNotFound());
            }
            return(View(repairsModels));
        }
Ejemplo n.º 8
0
        // GET: RepairsModels/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairsModels repairsModels = db.Repair.Find(id);

            if (repairsModels == null)
            {
                return(HttpNotFound());
            }
            string UserEmail = User.Identity.GetUserName();

            OwnerModels      owner = db.Owner.Single(a => a.Email == UserEmail);
            List <CarModels> Car   = db.Car.Where(a => a.OwnerID == owner.ID).ToList();

            ViewBag.CarId = new SelectList(Car, "ID", "Make", repairsModels.CarId);

            return(View(repairsModels));
        }