public ActionResult Edit(Machine machine, int EngineerId) { _db.Machines.Add(machine); if (EngineerId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Engineer engineer, int MachineId) { _db.Engineers.Add(engineer); if (MachineId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = engineer.EngineerId, MachineId = MachineId }); } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }