public ActionResult Create(Bug bug) { if (ModelState.IsValid) { db.Bugs.Add(bug); db.SaveChanges(); return RedirectToAction("Index"); } return View(bug); }
public ActionResult Create(Bug bug) { if (bug.Description == bug.Title) { ModelState.AddModelError("Description", "Description and Title should have different values!"); ModelState.AddModelError("Description", "Description and Title should have different values!123"); } if (ModelState.IsValid) { db.Bugs.Add(bug); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Categories = db.BugsCategories.ToList().Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }); return View(bug); }
public ActionResult Edit(Bug bug) { if (ModelState.IsValid) { db.Entry(bug).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Categories = db.BugsCategories.ToList().Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }); return View(bug); }