public ActionResult Edit(CHPInspection CHPInspection) { try { if (ModelState.IsValid) { db.CHPInspections.Attach(CHPInspection); db.Refresh(RefreshMode.KeepCurrentValues, CHPInspection); db.SubmitChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList(); ViewBag.FleetVehicles = db.FleetVehicles.OrderBy(p => p.VehicleNumber).ToList(); ViewBag.CHPOfficers = db.CHPOfficers.OrderBy(p => p.OfficerLastName).ToList(); ViewBag.InspectionTypes = db.InspectionTypes.OrderBy(p => p.InspectionType1).ToList(); return(View(CHPInspection)); }
public ActionResult DeleteConfirmed(Guid id) { CHPInspection CHPInspection = db.CHPInspections.Single(r => r.InspectionID == id); db.CHPInspections.DeleteOnSubmit(CHPInspection); db.SubmitChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(Guid id) { CHPInspection cHPInspection = await db.CHPInspections.FindAsync(id); db.CHPInspections.Remove(cHPInspection); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// // GET: /AdminArea/Freeways/Details/5 public ActionResult Details(Guid id) { CHPInspection CHPInspection = db.CHPInspections.Single(r => r.InspectionID == id); if (CHPInspection == null) { return(HttpNotFound()); } return(View(CHPInspection)); }
public async Task <ActionResult> Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CHPInspection cHPInspection = await db.CHPInspections.FindAsync(id); if (cHPInspection == null) { return(HttpNotFound()); } return(View(cHPInspection)); }
// // GET: /AdminArea/Freeways/Edit/5 public ActionResult Edit(Guid id) { ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList(); ViewBag.FleetVehicles = db.FleetVehicles.OrderBy(p => p.VehicleNumber).ToList(); ViewBag.CHPOfficers = db.CHPOfficers.OrderBy(p => p.OfficerLastName).ToList(); ViewBag.InspectionTypes = db.InspectionTypes.OrderBy(p => p.InspectionType1).ToList(); CHPInspection CHPInspection = db.CHPInspections.Single(r => r.InspectionID == id); if (CHPInspection == null) { return(HttpNotFound()); } return(View(CHPInspection)); }
public async Task <ActionResult> Edit([Bind(Include = "InspectionID,FleetVehicleID,CHPOfficerId,InspectionDate,InspectionTypeID,InspectionNotes,ContractorID")] CHPInspection cHPInspection) { if (ModelState.IsValid) { db.Entry(cHPInspection).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CHPOfficerId = new SelectList(db.CHPOfficers.Select(p => new { Id = p.Id, OfficerName = p.OfficerLastName + "," + p.OfficerFirstName }), "Id", "OfficerName", cHPInspection.CHPOfficerId); ViewBag.ContractorID = new SelectList(db.Contractors.OrderBy(p => p.ContractCompanyName), "ContractorID", "ContractCompanyName", cHPInspection.ContractorID); ViewBag.FleetVehicleID = new SelectList(db.FleetVehicles.OrderBy(p => p.FleetNumber), "FleetVehicleID", "FleetNumber", cHPInspection.FleetVehicleID); ViewBag.InspectionTypeID = new SelectList(db.InspectionTypes.OrderBy(p => p.InspectionType1), "InspectionTypeID", "InspectionType1", cHPInspection.InspectionTypeID); return(View(cHPInspection)); }
public ActionResult Create(CHPInspection CHPInspection) { if (ModelState.IsValid) { //if CHPInspection does not exist yet CHPInspection.InspectionID = Guid.NewGuid(); db.CHPInspections.InsertOnSubmit(CHPInspection); db.SubmitChanges(); return(RedirectToAction("Index")); } ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList(); ViewBag.FleetVehicles = db.FleetVehicles.OrderBy(p => p.VehicleNumber).ToList(); ViewBag.CHPOfficers = db.CHPOfficers.OrderBy(p => p.OfficerLastName).ToList(); ViewBag.InspectionTypes = db.InspectionTypes.OrderBy(p => p.InspectionType1).ToList(); return(View(CHPInspection)); }
public async Task <ActionResult> Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CHPInspection cHPInspection = await db.CHPInspections.FindAsync(id); if (cHPInspection == null) { return(HttpNotFound()); } ViewBag.CHPOfficerId = new SelectList(db.CHPOfficers.Select(p => new { Id = p.Id, OfficerName = p.OfficerLastName + ", " + p.OfficerFirstName }), "Id", "OfficerName", cHPInspection.CHPOfficerId); ViewBag.ContractorID = new SelectList(db.Contractors.OrderBy(p => p.ContractCompanyName), "ContractorID", "ContractCompanyName", cHPInspection.ContractorID); ViewBag.FleetVehicleID = new SelectList(db.FleetVehicles.OrderBy(p => p.FleetNumber), "FleetVehicleID", "FleetNumber", cHPInspection.FleetVehicleID); ViewBag.InspectionTypeID = new SelectList(db.InspectionTypes.OrderBy(p => p.InspectionType1), "InspectionTypeID", "InspectionType1", cHPInspection.InspectionTypeID); return(View(cHPInspection)); }