public ActionResult AddRohstoff(RohstoffViewViewModel _rohstoffView) { try { if (ModelState.IsValid) { _db.Rohstoffes.Add(_rohstoffView._Rohstoffe); _db.SaveChanges(); return(RedirectToAction(_rohstoffView._View)); } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return(HttpNotFound()); }
public ActionResult AddRohstoff(string whichView) { RohstoffViewViewModel r = new RohstoffViewViewModel(); r._View = whichView; return(View(r)); }
public ActionResult DeleteRohstoff(Rohstoffe _name, string roh) { if (_name == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RohstoffViewViewModel sd = new RohstoffViewViewModel(); _name.Id = Convert.ToInt32(_name.Name); sd._Rohstoffe = _db.Rohstoffes.FirstOrDefault(i => i.Id == _name.Id); sd._View = roh; if (sd._Rohstoffe == null) { return(HttpNotFound()); } return(View(sd)); }