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)); }
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)); }
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)); }
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)); }
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()); }
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")); }
// 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)); }
// 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)); }
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)); }
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)); }
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)); }
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")); }
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)); }