Exemplo n.º 1
0
 public ActionResult Add(User user, int[] selectedSkills)
 {
     if (selectedSkills != null)
     {
         foreach (var s in db.Skills().Where(sk => selectedSkills.Contains(sk.Id)))
         {
             user.Skills.Add(s);
         }
     }
     db.Create(user);
     return RedirectToAction("Index", "User");
 }
Exemplo n.º 2
0
 public ActionResult Edit(User user, int[] selectedSkills)
 {
     User newUser = db.GetById(user.Id);
     newUser.Name = user.Name;
     newUser.Age = user.Age;
     newUser.Gender = user.Gender;
     newUser.City = user.City;
     newUser.CityId = user.CityId;
     newUser.Skills.Clear();
     if (selectedSkills != null)
     {
         foreach (var s in db.Skills().Where(sk => selectedSkills.Contains(sk.Id)))
         {
             newUser.Skills.Add(s);
         }
     }
     db.Update(newUser);
     return RedirectToAction("Index", "User");
 }