public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommunicationSkill communicationSkill = db.CommunicationSkills.Find(id); if (communicationSkill == null) { return(HttpNotFound()); } CommunicationSkillViewModel model = new CommunicationSkillViewModel { Id = communicationSkill.CommunicationSkillId, SkillType = communicationSkill.SkillType, SkillLevel = communicationSkill.SkillLevel, }; ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName"); ViewBag.CommunicationSkillId = new SelectList(db.CommunicationSkills, "CommunicationSkillId", "SkillLevel"); return(View(model)); }
public ActionResult DeleteConfirmed(int id) { CommunicationSkill communicationSkill = db.CommunicationSkills.Find(id); db.CommunicationSkills.Remove(communicationSkill); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, CommunicationSkillViewModel model) { if (ModelState.IsValid) { CommunicationSkill communicationSkill = db.CommunicationSkills.Find(id); if (communicationSkill == null) { return(HttpNotFound()); } communicationSkill.SkillType = model.SkillType; communicationSkill.SkillLevel = model.SkillLevel; db.Entry(communicationSkill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName"); ViewBag.CommunicationSkillId = new SelectList(db.CommunicationSkills, "CommunicationSkillId", "SkillLevel"); return(View(model)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommunicationSkill communicationSkill = db.CommunicationSkills.Find(id); if (communicationSkill == null) { return(HttpNotFound()); } var model = new CommunicationSkillViewModel { Id = communicationSkill.CommunicationSkillId, EmployeeName = communicationSkill.Employee.FullName, SkillType = communicationSkill.SkillType, SkillLevel = communicationSkill.SkillLevel, }; return(View(model)); }
public ActionResult Create(CommunicationSkillViewModel model) { if (ModelState.IsValid) { var communicationSkill = new CommunicationSkill { CommunicationSkillId = model.Id, SkillType = model.SkillType, SkillLevel = model.SkillLevel, EmployeeId = model.EmployeeId, }; db.CommunicationSkills.Add(communicationSkill); db.SaveChanges(); return(RedirectToAction("Index")); } var list = db.Employees.ToList().Select(e => new { e.Id, e.FullName }); ViewBag.EmployeeId = new SelectList(list, "Id", "FullName"); ViewBag.CommunicationSkillId = new SelectList(db.CommunicationSkills, "CommunicationSkillId", "SkillLevel"); return(View(model)); }