public ActionResult Edit(Engineer engineer, int MachineId) { if (MachineId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { MachineId = MachineId, EngineerId = engineer.EngineerId }); } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, int EngineerId) { 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(Machine machine, int EngineerId) { var existingConnection = _db.MachineEngineer.FirstOrDefault(join => join.MachineId == machine.MachineId && join.EngineerId == EngineerId); if (existingConnection == null && EngineerId != 0) { _db.MachineEngineer.Add(new MachineEngineer() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Engineer engineer) { _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }