public ActionResult AddSkill(StaffSkillModel.StaffSkill model) { skill.StaffSkills.Add(model); // adding all new skills to the model skill.SaveChanges(); // save the changes. return(RedirectToAction("Skills", new { StaffCode = model.StaffCode })); //return to the view }
public ActionResult AddSkill(string StaffCode) { var skills = SkillClient.GetAllSkills(); //created variable skills to connect to the WCF client and get all skills. var allSkillsCode = (from s in skills select s.skillCode).ToList(); //variable allSkillsCode containing all skills in the WCF client. var thisStaffSkillsCode = (from s in skill.StaffSkills where s.StaffCode == StaffCode select s.SkillCode).ToList(); // variable thisStaffSkillsCode lists a staff members skill codes. var yetToHave = allSkillsCode.Except(thisStaffSkillsCode); // variable yetToHave lists skills left to go on the members skill list. List <skillVM> list = buildSkillList(skills, yetToHave); // ViewBag.skillCode = new SelectList(list, "skillCode", "skillDescription"); // this created a clickable dropdown list containing all skillCodes / skillDescriptions var model = new StaffSkillModel.StaffSkill(); //variable model creating a new instance of the StaffSkillModel return(View("AddSkill", model)); //return the newly created model in the view. }