public ActionResult Create(Issue issue, string companyId = null) { if (ModelState.IsValid) { if (companyId != null) issue.Companies.Add(db.Companies.Find(companyId)); db.Issues.Add(issue); db.SaveChanges(); return RedirectToAction("Index"); } return View(issue); }
// // GET: /Issue/Create public ActionResult Create(int? companyId = null, bool wizard = false) { if (companyId != null) { Company owner = db.Companies.Where(c => c.Id == companyId).FirstOrDefault(); ViewBag.CompanyId = companyId; } Issue newIssue = new Issue { Opened = DateTime.Now, State = IssueState.OPEN }; db.Issues.Add(newIssue); db.SaveChanges(); ViewBag.Wizard = wizard; return View("Edit", newIssue); }
public ActionResult Edit(Issue issue, bool wizard = false) { if (ModelState.IsValid) { db.Entry(issue).State = EntityState.Modified; db.SaveChanges(); if (wizard) return RedirectToAction("Create", "Call", new { issueId = issue.Id }); return RedirectToAction("Index"); } return View(issue); }