Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            CHPInspection CHPInspection = db.CHPInspections.Single(r => r.InspectionID == id);

            db.CHPInspections.DeleteOnSubmit(CHPInspection);
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            CHPInspection cHPInspection = await db.CHPInspections.FindAsync(id);

            db.CHPInspections.Remove(cHPInspection);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        //
        // 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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        //
        // 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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }