public ActionResult Create(Technician technician, Location location, Skill skill) { if (ModelState.IsValid) { db.Locations.Add(location); db.Skills.Add((Skill)skill); db.SaveChanges(); //var skill = db.Skills.First((System.Linq.Expressions.Expression<System.Func<Skill, bool>>)(s => s.Name == skill.Name && s.SkillType == skill.SkillType)); technician.CurrentLocation = location; technician.Skills = new List<Skill>(); technician.Skills.Add(skill); db.Technicians.Add(technician); db.SaveChanges(); return RedirectToAction("Index"); } return View(technician); }
public ActionResult Edit(Technician technician, Location location, Skill skill) { if (ModelState.IsValid) { db.Entry(technician).State = EntityState.Modified; db.Entry(location).State = EntityState.Modified; db.Entry(skill).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(technician); }