コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }