public JsonResult GetSkills(List <Member> list) { var user = SessionHelper.Get <Member>(Constant.SESSION_LOGIN); if (user == null) { return(Json(new { body = "" }, JsonRequestBehavior.AllowGet)); } using (var db = new UMC_SKILLEntities()) { var listCerByUser = new List <CertificateByUser>(); foreach (var u in list) { var skills = db.Certifications.Include("Skill").Where(m => m.UserID == u.ID && m.Skill.Removed == 0).ToList(); var allSkill = db.Skills.Where(m => m.Removed == 0).ToList(); Dictionary <Skill, Certification> dics = new Dictionary <Skill, Certification>(); var cerByUser = new CertificateByUser() { userID = u.ID, Code = u.Code, FullName = u.Name, Dept = u.Dept, Customer = u.Customer, ListSkills = skills }; foreach (var skill in allSkill) { var cer = skills.Where(m => m.SkillID == skill.ID).FirstOrDefault(); dics.Add(skill, cer); } cerByUser.dics = dics; listCerByUser.Add(cerByUser); } if (listCerByUser != null && listCerByUser.Count > 0) { return(Json(new { body = Utils.ConvertViewToString("~/Views/Home/_AllSkillOfStaff.cshtml", listCerByUser, ViewData, ControllerContext), }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { body = "" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult ViewSkillForStaff(int ID = 0) { var user = SessionHelper.Get <Member>(Constant.SESSION_LOGIN); if (user != null) { if (ID != 0) { using (var db = new UMC_SKILLEntities()) { var u = db.Members.Where(m => m.ID == ID).FirstOrDefault(); var skills = db.Certifications.Include("Skill") .Where(m => m.UserID == u.ID && m.Skill.Removed == 0) .ToList(); var cerByUser = new CertificateByUser() { userID = u.ID, Code = u.Code, FullName = u.Name, Dept = u.Dept, DateEnter = u.DateEnter.ToShortDateString(), ListSkills = skills, Customer = u.Customer }; if (cerByUser != null) { return(View(cerByUser)); } } } return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Login")); } }