public ActionResult Edit([Bind(Include = "User_Skills_ID,UserId,SkillID")] User_Skills user_Skills) { user_Skills.UserId = User.Identity.GetUserId(); if (ModelState.IsValid) { db.Entry(user_Skills).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SkillID = new SelectList(db.Skill, "Skill_Id", "Title", user_Skills.SkillID); //ViewBag.UserId = new SelectList(db.Users, "Id", "Fname", user_Skills.UserId); return(View(user_Skills)); }
// GET: User_Skills/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Skills user_Skills = db.User_Skills.Find(id); if (user_Skills == null) { return(HttpNotFound()); } return(View(user_Skills)); }
// GET: User_Skills/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Skills user_Skills = db.User_Skills.Find(id); if (user_Skills == null) { return(HttpNotFound()); } ViewBag.SkillID = new SelectList(db.Skill, "Skill_Id", "Title", user_Skills.SkillID); //ViewBag.UserId = new SelectList(db.Users, "Id", "Fname", user_Skills.UserId); return(View(user_Skills)); }
public ActionResult Create([Bind(Include = "User_Skills_ID,UserId,SkillID")] User_Skills user_Skills) { user_Skills.UserId = User.Identity.GetUserId(); if (ModelState.IsValid) { ApplicationUser theUser = db.Users.Find(User.Identity.GetUserId()); user_Skills.Skill = db.Skill.Find(user_Skills.SkillID); theUser.TecSkills.Add(user_Skills.Skill); db.User_Skills.Add(user_Skills); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SkillID = new SelectList(db.Skill, "Skill_Id", "Title", user_Skills.SkillID); //ViewBag.UserId = new SelectList(db.Users, "Id", "Fname", user_Skills.UserId); return(View(user_Skills)); }
public ActionResult AddSkill(int SkillId, int WeightRange) { ApplicationUser exuser = db.Users.Find(User.Identity.GetUserId()); Skill skill = db.Skill.Find(SkillId); if (CurrentUser.User_TecSkills.FirstOrDefault(x => x.SkillID == SkillId) == null) { User_Skills user_Skill = new User_Skills() { UserId = CurrentUser.Id, SkillID = SkillId, Weight = WeightRange, Skill = skill }; exuser.TecSkills.Add(skill); db.User_Skills.Add(user_Skill); db.SaveChanges(); } return(RedirectToAction("MySkills")); }