Exemplo n.º 1
0
        public ActionResult AddSkill(Models.StaffSkill model)
        {
            StaffSkillsDbfModel.staffSkill newSkill = new StaffSkillsDbfModel.staffSkill
            {
                skillCode = model.skillCode,
                staffCode = model.staffCode,
                active    = true
            };

            skill_db.staffSkills.Add(newSkill);
            skill_db.SaveChanges();

            return(RedirectToAction("Skills", new { id = model.staffCode }));
        }
Exemplo n.º 2
0
        public ActionResult AddSkill(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new HttpException(400, "Bad Request");
            }

            Models.StaffDTO staff = null;

            HttpClient sClient = new HttpClient();

            sClient.BaseAddress = new System.Uri("http://localhost:65026");
            sClient.DefaultRequestHeaders.Accept.ParseAdd("application/json");
            HttpResponseMessage response = sClient.GetAsync("api/Staff/" + id).Result;

            if (response.IsSuccessStatusCode)
            {
                staff = response.Content.ReadAsAsync <Models.StaffDTO>().Result;
            }

            var skills              = WCFClient.GetAllSkills();
            var allSkillsCode       = (from s in skills select s.skillCode).ToList();
            var thisStaffSkillsCode = (from s in skill_db.staffSkills
                                       where s.staffCode == id
                                       select s.skillCode).ToList();
            var yetToHave = allSkillsCode.Except(thisStaffSkillsCode);

            List <Models.SkillVM> list = Models.SkillVM.buildList(skills, yetToHave);

            ViewBag.skillCode = new SelectList(list, "skillCode", "skillDescription");

            Models.StaffSkill staffSkillVM = new Models.StaffSkill
            {
                staffCode = staff.staffCode,
                fullName  = staff.fullName
            };

            return(View(staffSkillVM));
        }