public ActionResult AddOrEdit(Ticket emp) { using (BugDBEntities db = new BugDBEntities()) { if (emp.TicketID == 0) { db.Tickets.Add(emp); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddorEdit(SelectedCategory emp) { //multi select dropdown emp.SelectedCategoryIDs = string.Join(",", emp.SelectedIDArray); using (BugDBEntities db = new BugDBEntities()) { if (emp.ID == 0) { db.SelectedCategories.Add(emp); } else { db.Entry(emp).State = EntityState.Modified; } db.SaveChanges(); } return(RedirectToAction("AddOrEdit", new { id = 0 })); }