public ActionResult Edit(InstructionWork model, string submitVal) { try { if (ModelState.IsValid) { if (submitVal == "nueva version") { HistInstructionWork histInstWork = new HistInstructionWork(model); histInstWork.changeReason = model.changeReason; db.HistInstructionWorks.Add(histInstWork); db.SaveChanges(); } model.version++; model.updateDate = DateTime.Now; db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); } catch { return(View("Error", null)); } }
public ActionResult Delete(int id) { InstructionWork model = db.InstructionWorks .Include(m => m.Process) .Include(m => m.Rule) .Include(m => m.User) .Include(m => m.Department) .FirstOrDefault(m => m.ID == id); return(View(model)); }
public ActionResult Create() { int?companyID = db.Users.Find(WebSecurity.CurrentUserId).companyID; ViewBag.ruleID = Helper.GetRulesSelect(db); ViewBag.processID = new SelectList(db.Processes.Where(dep => dep.companyID == companyID), "ID", "name"); ViewBag.departmentID = new SelectList(db.Departments.Where(dep => dep.companyID == companyID), "ID", "name"); ViewBag.responsible = new SelectList(db.Users, "ID", "name"); InstructionWork model = new InstructionWork(); return(View(model)); }
public ActionResult DeleteConfirmed(int id) { InstructionWork model = db.InstructionWorks .Include(iw => iw.Tasks) .FirstOrDefault(iw => iw.ID == id); model.Tasks.ToList().ForEach(t => db.Tasks.Remove(t)); model.HistInstructionWorks.ToList().ForEach(t => db.HistInstructionWorks.Remove(t)); db.SaveChanges(); db.InstructionWorks.Remove(model); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(InstructionWork model) { try { if (ModelState.IsValid) { model.statusID = (int)Helper.StatusTypes.Creacion; model.createUser = WebSecurity.CurrentUserId; model.companyID = (int)db.Users.Find(model.createUser).companyID; db.InstructionWorks.Add(model); db.SaveChanges(); return(RedirectToAction("Edit", new { id = model.ID })); } return(View(model)); } catch { return(View("Error", null)); } }