public ActionResult Create([Bind(Include = "Id,ElementId,DefectId,AdresId,Sostoyanie,Opisanie,Date")] ActiveDefect activeDefect)
        {
            if (activeDefect.Sostoyanie > 10)
            {
                activeDefect.Sostoyanie = 10;
            }
            if (activeDefect.Sostoyanie < 1)
            {
                activeDefect.Sostoyanie = 1;
            }
            if (activeDefect.Date.Year == 1)
            {
                activeDefect.Date = DateTime.Now;
            }


            db.ActiveDefects.Add(activeDefect);
            db.SaveChanges();
            return(RedirectToAction("Index"));


            ViewBag.AdresId   = new SelectList(db.Adres, "Id", "Adress", activeDefect.AdresId);
            ViewBag.DefectId  = new SelectList(db.Defects, "Id", "Def", activeDefect.DefectId);
            ViewBag.ElementId = new SelectList(db.Elements, "Id", "Name", activeDefect.ElementId);
            return(View(activeDefect));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ActiveDefect activeDefect = db.ActiveDefects.Find(id);

            db.ActiveDefects.Remove(activeDefect);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,ElementId,DefectId,AdresId,Sostoyanie,Opisanie,Date")] ActiveDefect activeDefect)
 {
     if (ModelState.IsValid)
     {
         db.Entry(activeDefect).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AdresId   = new SelectList(db.Adres, "Id", "Adress", activeDefect.AdresId);
     ViewBag.DefectId  = new SelectList(db.Defects, "Id", "Def", activeDefect.DefectId);
     ViewBag.ElementId = new SelectList(db.Elements, "Id", "Name", activeDefect.ElementId);
     return(View(activeDefect));
 }
        // GET: ActiveDefects/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ActiveDefect activeDefect = db.ActiveDefects.Find(id);

            if (activeDefect == null)
            {
                return(HttpNotFound());
            }
            return(View(activeDefect));
        }
        // GET: ActiveDefects/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ActiveDefect activeDefect = db.ActiveDefects.Find(id);

            if (activeDefect == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AdresId   = new SelectList(db.Adres, "Id", "Adress", activeDefect.AdresId);
            ViewBag.DefectId  = new SelectList(db.Defects, "Id", "Def", activeDefect.DefectId);
            ViewBag.ElementId = new SelectList(db.Elements, "Id", "Name", activeDefect.ElementId);
            return(View(activeDefect));
        }