public ActionResult Edit([Bind(Include = "ID, StartDate, EndDate, RepairStatus, Customer, Technician, HoursWorkedOn, Description, RepairOrder, CustomerId")] VMRepairOrderEdit vmRepairOrder) { if (ModelState.IsValid) { RepairOrder repairOrder = vmRepairOrder.RepairOrder; db.Entry(repairOrder).State = EntityState.Modified; db.SaveChanges(); //Find the repairOrder in the database based on the ID. repairOrder = db.RepairOrders.Find(vmRepairOrder.RepairOrder.ID); //If CustomerId has a value. (Which means the list was changed?) //Find Customer in Customers and set it to be repairOrder's Customer? if (vmRepairOrder.CustomerId != null) { //Load Customer first before altering. Otherwise Customer remains null. db.Entry(repairOrder).Reference(c => c.Customer).Load(); //Find said Customer in the database and set it as the customer? repairOrder.Customer = db.Customers.Find(vmRepairOrder.CustomerId); } if (vmRepairOrder.TechnicianId != null) { db.Entry(repairOrder).Reference(c => c.Technician).Load(); repairOrder.Technician = db.Technicians.Find(vmRepairOrder.TechnicianId); } db.Entry(repairOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vmRepairOrder)); }
public ActionResult Edit([Bind(Include = "PartId,PartName,Price,PartStatus")] Part part) { if (ModelState.IsValid) { db.Entry(part).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(part)); }
public ActionResult Edit([Bind(Include = "customerid,external_key,create_date,createdby,modify_date,modify_by,ffirst_name,last_name,user_name,password,marketable,active,email_address,customer_comment,shop_id")] customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "StockPartID,CatlPartID,PartStatus")] StockPart stockPart) { if (ModelState.IsValid) { db.Entry(stockPart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CatlPartId = new SelectList(db.CatlParts, "CatlPartId", "PartName", stockPart.StockPartID); return(View(stockPart)); }
public ActionResult Edit([Bind(Include = "vehicle_id,customer_id,vin,year,make,model,active,create_date,created_by")] customer_vehicles customer_vehicles) { if (ModelState.IsValid) { db.Entry(customer_vehicles).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customer_id = new SelectList(db.customers, "customerid", "external_key", customer_vehicles.customer_id); return(View(customer_vehicles)); }