public ActionResult DeleteIndikator(Umweltindikator _name, string indi) { if (_name == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IndikatorViewViewModel sd = new IndikatorViewViewModel(); _name.Id = Convert.ToInt32(_name.Name); sd._Umweltindikator = _db.Umweltindikators.FirstOrDefault(i => i.Id == _name.Id); sd._View = indi; if (sd._Umweltindikator == null) { return(HttpNotFound()); } return(View(sd)); }
public ActionResult DeleteIndikatorConfirmed(Umweltindikator _name, string indi) { _name.Id = Convert.ToInt32(_name.Name); var pa = from a in _db.Umweltindikators where a.Id == _name.Id select a; Umweltindikator asdd = pa.FirstOrDefault(); if (asdd != null) { //Finde alle Umweltindikator var uw = _db.Umweltindikatorwerts.Select(s => s).ToList(); for (int i = 0; i < uw.Count(); i++) { if (uw.ElementAt(i).Umweltindikator_Id == _name.Id) { _db.Umweltindikatorwerts.Remove(uw.ElementAt(i)); } } _db.Umweltindikators.Remove(asdd); } _db.SaveChanges(); return(RedirectToAction(indi)); }