public ActionResult Create(Customer customer, Location location) { if (ModelState.IsValid) { db.Locations.Add(location); customer.CustomerLocation = location; db.Customers.Add(customer); db.SaveChanges(); return RedirectToAction("Index"); } return View(customer); }
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); }
public ActionResult Index(Location currentLocation, Technician tech) { var technician = db.Technicians.Find(tech.TechnicianId); technician.CurrentLocation = currentLocation; db.Entry(technician).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index", new { id = tech.TechnicianId }); }