//
        // GET: /SpecRating/Details/5

        public ActionResult Details(int id = 0)
        {
            SpecRating specrating = db.SpecRatings.Find(id);

            if (specrating == null)
            {
                return(HttpNotFound());
            }
            return(View(specrating));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SpecRating specrating = db.SpecRatings.Find(id);

            db.SpecRatings.Remove(specrating);
            db.SaveChanges();
            if (Insert_CodeLookUp_Audit("Specification", "Delete", specrating.SpecRatingItem, ""))
            {
                //nothing to do at this point.
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(SpecRating specrating)
 {
     if (ModelState.IsValid)
     {
         db.Entry(specrating).State = EntityState.Modified;
         db.SaveChanges();
         if (Insert_CodeLookUp_Audit("Specification", "Edit", Session["CodeLookUpAduit_Oldvalue"].ToString(), specrating.SpecRatingItem))
         {
             //nothing to do at this point.
         }
         return(RedirectToAction("Index"));
     }
     return(View(specrating));
 }
        public ActionResult Create(SpecRating specrating)
        {
            if (ModelState.IsValid)
            {
                db.SpecRatings.Add(specrating);
                db.SaveChanges();
                if (Insert_CodeLookUp_Audit("Specification", "Create", "", specrating.SpecRatingItem))
                {
                    //nothing to do at this point.
                }
                return(RedirectToAction("Index"));
            }

            return(View(specrating));
        }
        //
        // GET: /SpecRating/Delete/5

        public ActionResult Delete(int id = 0)
        {
            SpecRating specrating   = db.SpecRatings.Find(id);
            var        specfeatures = (from vf in db.ValveSectionFeatures
                                       where vf.SpecRatingID == specrating.SpecRatingID
                                       select new
            {
                vf
            }).ToList();


            if (specfeatures.Count > 0)
            {
                ModelState.AddModelError("SpecRatingItem", "This Specification is assigned to Circuit feature(s) and cannot be deleted.");
                ViewBag.HasError = "True";
            }
            if (specrating == null)
            {
                return(HttpNotFound());
            }
            return(View(specrating));
        }
        //
        // GET: /SpecRating/Edit/5

        public ActionResult Edit(int id = 0)
        {
            SpecRating specrating   = db.SpecRatings.Find(id);
            var        specfeatures = (from vf in db.ValveSectionFeatures
                                       where vf.SpecRatingID == specrating.SpecRatingID
                                       select new
            {
                vf
            }).ToList();


            if (specfeatures.Count > 0)
            {
                ModelState.AddModelError("SpecRatingItem", "Warning! This Specification is assigned to Circuit feature(s).");
                ViewBag.HasError = "True";
            }
            if (specrating == null)
            {
                return(HttpNotFound());
            }
            Session["CodeLookUpAduit_Oldvalue"] = specrating.SpecRatingItem;
            return(View(specrating));
        }