public ActionResult Edit(ViewModelAufgabe _produktDetails) { try { if (ModelState.IsValid) { _db.Entry(_produktDetails._main).State = EntityState.Modified; _produktDetails._main.Änderungsdatum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); _db.SaveChanges(); return(RedirectToAction("Index")); } } 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(View(_produktDetails)); }
public ActionResult Create(ViewModelAufgabe vmodel = null) { ViewModelAufgabe _viewmodel = new ViewModelAufgabe(); _viewmodel._lKategorie = _db.Kategorie.ToList(); return(View(_viewmodel)); }
public ActionResult CreateConfirmed(ViewModelAufgabe _aufgabe) { try { if (ModelState.IsValid) { _aufgabe._main.Anlegedatum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); _aufgabe._main.Änderungsdatum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); _aufgabe._main.isDone = false; _aufgabe._main.Kategorie_Id = _aufgabe._kategorie.Id; _db.main.Add(_aufgabe._main); _db.SaveChanges(); int id = _aufgabe._main.Id; //Indikator speichern return(RedirectToAction("Index")); } } 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 Details(int?Id) { main proid = _db.main.Find(Id); Kategorie viewKat = _db.Kategorie.Find(proid.Kategorie_Id); ViewModelAufgabe _view = new ViewModelAufgabe(); _view._main = proid; _view._kategorie = viewKat; return(View(_view)); }
public ActionResult Edit(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var p = from a in _db.main where a.Id == Id select a; ViewModelAufgabe vMA = new ViewModelAufgabe(); vMA._main = p.FirstOrDefault(); vMA._lKategorie = _db.Kategorie.ToList(); if (vMA._main == null) { return(HttpNotFound()); } return(View(vMA)); }