Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            RepairModels repairModels = db.Repair.Find(id);

            db.Repair.Remove(repairModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,CarId,Name,Description,ServiceCost,PartId")] RepairModels repairModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(repairModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(repairModels));
 }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "ID,CarID,Name,Desc,PriceOfRepair")] RepairModels repairModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(repairModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarID = new SelectList(db.Car, "ID", "Mark", repairModels.CarID);
     return(View(repairModels));
 }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "Id,CarID,Name,Description,RepairAmount")] RepairModels repairModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(repairModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id = new SelectList(db.Car, "Id", "Make", repairModels.Id);
     return(View(repairModels));
 }
        public ActionResult Create([Bind(Include = "ID,CarId,Name,Description,ServiceCost,PartId")] RepairModels repairModels)
        {
            if (ModelState.IsValid)
            {
                db.Repairs.Add(repairModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(repairModels));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "ID,CarID,Name,Desc,PriceOfRepair")] RepairModels repairModels)
        {
            if (ModelState.IsValid)
            {
                db.Repair.Add(repairModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CarID = new SelectList(db.Car, "ID", "Mark", repairModels.CarID);
            return(View(repairModels));
        }
Esempio n. 7
0
        public ActionResult Create(int?id)
        {
            if (id != null)
            {
                CarModels    car    = db.Cars.Where(c => c.ID == id).FirstOrDefault();
                OwnerModels  owner  = db.Owners.Where(o => o.Cars.Contains(car)).FirstOrDefault();
                RepairModels repair = db.Repairs.Where(r => r.Car.Owner == owner).FirstOrDefault();
                return(View(repair));
            }

            ViewBag.CarId = new SelectList(db.Cars, "ID", "Model");
            return(View());
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "CarId,Name,Description,Cost")] RepairModels repairModels)
        {
            ViewBag.CarId = new SelectList(db.Cars, "ID", "Model", repairModels.CarId);


            var Car = db.Cars.Where(a => a.ID == repairModels.CarId).FirstOrDefault();

            repairModels.Car = Car;

            db.Repairs.Add(repairModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        // GET: Repair/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairModels repairModels = db.Repair.Find(id);

            if (repairModels == null)
            {
                return(HttpNotFound());
            }
            return(View(repairModels));
        }
Esempio n. 10
0
        // GET: Repair/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairModels repairModels = db.Repair.Find(id);

            if (repairModels == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CarID = new SelectList(db.Car, "ID", "Mark", repairModels.CarID);
            return(View(repairModels));
        }
Esempio n. 11
0
        public ActionResult Create([Bind(Include = "Id,CarID,Name,Description,RepairAmount")] RepairModels repairModels)
        {
            if (ModelState.IsValid)
            {
                repairModels.RepairAmount = 0;
                db.Reapirs.Add(repairModels);


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.Id = new SelectList(db.Car, "Id", "Make", repairModels.Id);
            return(View(repairModels));
        }
Esempio n. 12
0
        public ActionResult DeleteRepair()
        {
            int?id = Int32.Parse(Request.Form.Get("id"));

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairModels repairModels = db.Reapirs.Find(id);

            if (repairModels == null)
            {
                return(HttpNotFound());
            }
            return(View(repairModels));
        }
Esempio n. 13
0
        public ActionResult Details()
        {
            int?id = Int32.Parse(Request.Form.Get("id"));

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairModels repairModels = db.Reapirs.Find(id);

            ViewBag.PartList = db.Parts.Where(i => i.RepairID == id);
            if (repairModels == null)
            {
                return(HttpNotFound());
            }
            return(View(repairModels));
        }
Esempio n. 14
0
        public ActionResult DeleteConfirmed()
        {
            int?id = Int32.Parse(Request.Form.Get("id"));

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            RepairModels repairModels = db.Reapirs.Find(id);

            db.Parts.Where(i => i.RepairID == id).ToList().ForEach(p => db.Parts.Remove(p));
            db.SaveChanges();
            db.Reapirs.Remove(repairModels);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 15
0
        public ActionResult EditRepair()
        {
            int?id = Int32.Parse(Request.Form.Get("id"));

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepairModels repairModels = db.Reapirs.Find(id);
            int          ownerId      = (int)Session["UserId"];

            if (repairModels == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Id    = new SelectList(db.Car.Where(c => c.OwnerID == ownerId && c.Id == repairModels.CarID), "Id", "Make");
            ViewBag.CarId = new SelectList(db.Car.Where(c => c.OwnerID == ownerId && c.Id == repairModels.CarID), "Id", "Make", repairModels.Id);
            return(View(repairModels));
        }