コード例 #1
0
 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());
 }
コード例 #2
0
        public ActionResult AddRohstoff(string whichView)
        {
            RohstoffViewViewModel r = new RohstoffViewViewModel();

            r._View = whichView;
            return(View(r));
        }
コード例 #3
0
        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));
        }